'AND' Toán tử logic
Toán tử 'AND' là một toán tử logic AND nhưng có mức độ ưu tiên thấp đối với toán tử =.
'&&' Toán tử logic
'&&' cũng là một toán tử logic AND nhưng có mức độ ưu tiên cao hơn toán tử =.
Ví dụ
Sau ví dụ, cho thấy sự khác biệt của toán tử 'AND' so với '&&'.
<!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> Đầu ra
$result = $x AND $y bool(true) $result = $x && $y bool(false)