Here is my PHP code:
<?php
$a = 76;
$b = true;
$c = 0;
$d = 500;
$check = (
($a > 0) &&
($b == false) &&
($c == 0) &&
($d > 0)
);
echo '[' . $check . ']' . "\n"; //echoes []
// -------------------------------
$a = 76;
$b = false;
$c = 0;
$d = 500;
$check = (
($a > 0) &&
($b == false) &&
($c == 0) &&
($d > 0)
);
echo '[' . $check . ']' . "\n";
?>
This generates this error:
PHP Fatal error: Uncaught Error: Call to undefined function () in /home/abc/code/php_test/test_boolean.php:26
Stack trace:
#0 {main}
thrown in /home/abc/code/php_test/test_boolean.php on line 26
I can't figure out why this error is occurring. Why does changing $b to false make it think it's a function call?
I get this error if I run it in the browser or on the command line. However, testing it in different online php testers doesn't cause an error and produces the expected output. I don't know why this is causing an error on my local. I tried with both php7.3.31 and php 8.0.12