View Full Version : Please explain this behavior of unserialize

06-17-2005, 09:56 AM

$foo = unserialize('');

echo count($foo);
// echoes 1

// echoes nothing


06-17-2005, 03:03 PM
Unserialize is used on arrays that have been serialized.

06-17-2005, 03:07 PM
from the manual on count (http://www.php.net/manual/en/function.count.php):

If var is not an array or an object with implemented Countable interface, 1 will be returned.

and in your example $foo will be set to boolean false, so it cannot be "counted".

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum