Description
Hi,
I wondered about the result of checking the string "0" with the function empty.
The string isn't empty obviously, but as "empty" is a short version of
!isset($var) || $var == false
. "0" is casted to false. This is as defined, but astonishing, if you take the word empty verbatim.
Is it really the result developers expect, when checking a variable containing the string "0"?
The following code:
<?php
var_dump(empty("0"));
?>
Resulted in this output:
But I expected this output instead:
PHP Version
PHP 8.2.26
Operating System
Debian 12