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 …
在PHP中,运算符!=和<>运算符之间有什么区别吗?
在手册中,它指出:
$a != $b Not equal TRUE if $a is not equal to $b after type juggling.
$a <> $b Not equal TRUE if $a is not equal to $b after type juggling.
Run Code Online (Sandbox Code Playgroud)
我想没有太大的差异,但我很好奇.
以下代码有什么作用?PHP手册中某些内容的链接也很不错.
if ($_SERVER['SERVER_PORT'] <> 443) {
doSomething();
}
Run Code Online (Sandbox Code Playgroud) 什么是<>运营商意味着什么?
它是否相同!=(不相等)?
$foo = 'text';
if ($foo <> 'photo') {
echo 'foo';
}
else {
echo 'bar';
}
Run Code Online (Sandbox Code Playgroud)