2 ms·
If you really want to test for empty strings where $a is defined just use: if ($a == "") { ... } Empty is merely the function equivalent of the not (!) op
by wvenable 12y ago
If you really want to test for empty strings where $a is defined just use:
if ($a == "") { ... }
Empty is merely the function equivalent of the not (!) operator. The semantics are exactly the same except for the handling of undefined variables. It's not something one should use except if you're expecting to deal with undefined variables.
- chriswarbo 12y ago> Empty is merely the function equivalent of the not (!) operator. Nope! "empty" is an operator too: var_dump(array_map('empty', [null, '', 5, false])); PHP Warning: array_map() expects parameter 1 to be a valid callback, function 'empty' not found or invalid function name NULL See https://bugs.php.net/bug.php?id=66368 https://bugs.php.net/bug.php?id=66368