使用 ?:
条件运算符和 ||
逻辑 OR
有什么区别。
我发现我的代码适用于:
$screenpixelratio = !empty($_COOKIE['screenpixelratio']) || $_COOKIE['screenpixelratio'] || $fallback_pixelratio;
但不是:
$screenpixelratio = !empty($_COOKIE['screenpixelratio']) ? $_COOKIE['screenpixelratio'] : $fallback_pixelratio;
有人可以解释一下为什么它适用于一个,但不能适用于另一个。
最佳答案
第一个 ( conditional or ) 是说...
this or this or this
另一个 ( ternary operation ) 在说
if this then this otherwise that
关于php - 有什么区别? : and ||,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14897901/