This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.
It used to be hard to find questions about operators and other syntax tokens.¹
The main idea is to have links to existing questions on Stack Overflow, so it's easier for us to reference them, not to copy over content from …
我有一个代码库,开发人员决定使用AND而OR不是&&和||.
我知道运营商的优先级(&&之前and)有所不同,但是对于给定的框架(PrestaShop来说准确),显然不是理由.
你使用的是哪个版本?是and不是更具有可读性&&?或者没有区别?
我有以下的代码,并且不认为和需要,即&&应该使用,因为没有什么左边部分分配给?
if($_REQUEST['foo'] != 'abc' and $_REQUEST['bar'] == 'def')
{
echo "all your base";
}
Run Code Online (Sandbox Code Playgroud)
所以它应该是:
if($_REQUEST['foo'] != 'abc' && $_REQUEST['bar'] == 'def')
{
echo "all your base";
}
Run Code Online (Sandbox Code Playgroud)