PHP中AND和&&运算符之间的区别
“AND”逻辑运算符
“AND”运算符是逻辑AND运算符,但其优先级低于=运算符。
'&&'逻辑运算符
'&&'也是逻辑AND运算符,但优先于=运算符。
示例
下面的示例显示了'AND'与'&&'运算符的区别。
<!DOCTYPE html>
<html>
<head>
<title>PHP Example</title>
</head>
<body>
<?php
$x = true;
$y = false;
$result = $x AND $y;
print('$result = $x AND $y');
print("<br/>");
var_dump($result);
print("<br/>");
$result = $x && $y;
print('$result = $x && $y');
print("<br/>");
var_dump($result);
?>
</body>
</html>输出结果
$result = $x AND $y bool(true) $result = $x && $y bool(false)
热门推荐
10 圣诞祝福语简短小学
11 祖国七十华诞简短祝福语
12 老师送的祝福语简短
13 生日祝福语大全女生简短
14 祝女性生日祝福语简短
15 牛年女神节祝福语简短
16 情人表白祝福语简短大气
17 老公开业祝福语简短
18 官宣新年祝福语简短