-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed as not planned
Labels
Description
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:
bool(true)
But I expected this output instead:
bool(false)
PHP Version
PHP 8.2.26
Operating System
Debian 12