本身没有区别,习惯问题 ,但是有时候牵涉到运算符优先级的问题,结果会不同,记录下。
例如:
$p = 6 or 0;
var_dump($p);//int(6)
$p = 6 || 0;
var_dump($p);//bool(true)
$p = 6 and 0;
var_dump($p); //int(6)
$p = 6 && 0;
var_dump($p); //bool(false)
因为赋值运算的优先级比AND和OR的高,所以先赋值;比&&和||的低,所以逻辑运算符先执行,先逻辑运算,再赋值。
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn