...

View Full Version : Please explain this behavior of unserialize



maltrecho
06-17-2005, 10:56 AM
<?php

$foo = unserialize('');

echo count($foo);
// echoes 1

print_r($foo);
// echoes nothing

?>

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

devinemke
06-17-2005, 04: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