var_dump((array)"");
Results in:
array(1) {
[0]=>
string(0) ""
}
And 'array("")' is not empty.
-- Jille
Op 13-1-2010 14:50, Etienne Kneuss schreef:
Hello,
On Wed, Jan 13, 2010 at 2:36 PM, mathieu.suen
<mathieu.s...@easyflirt.com> wrote:
Hi,
I came across this:
echo sizeof(array());
echo sizeof("");
$a = "";
php.net/count:
"If var is not an array or an object with implemented Countable
interface, 1 will be returned. There is one exception, if var is NULL,
0 will be returned."
var_dump( empty($a));
$a = array();
var_dump(empty($a));
php.net/empty
empty($var) is basically an !isset($var) || !$var
it's not related to count in anyway.
So funny! How something can have a size greater than 0 but still be empty?
I think PHP is reinventing the inconsistency word.
I think such comments are pretty useless. Try coming with a viable
solution as a patch instead.
But then let assume that empty is just making a cast in array.
If you assume wrong, you can derive all kind of madness.
$a = "";
empty($a) //true
empty((array)$a) //false
Ok so empty is big ugly switch case on type.
No, it's a boolean check, with type juggling involed, see above.
empty(0); //true
empty(45); //false
Wooow reinventing emptiness on number....
-- Mathieu Suen
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php