unserialize_callback_func
Adam Fields
fields at surgam.net
Sun Oct 27 21:16:48 EST 2002
I'm trying to use unserialize_callback_func to set up an autoloader
function to be called if an object is unserialized and the class
hasn't been defined yet.
However, it doesn't seem to work - the callback function isn't getting
called.
I tried ini_set and setting the value explicitly in the php.ini, but
it doesn't call the function.
Drawing on the example from the docs:
-------------------
function __unser($class)
{
die ("Callback");
}
ini_set('unserialize_callback_func','__unser');
$serialized_object='O:1:"a":1:{s:5:"value";s:3:"100";}';
print_r (unserialize($serialized_object));
-------------------
should print "Callback", but instead, it prints (as expected without
the callback) "Array ( ) __PHP_Incomplete_Class Object (
[__PHP_Incomplete_Class_Name] => a [value] => 100 ) ".
Has anyone used this successfully?
Also, assuming there's a way to do this, does anyone know if this
callback can be a class method for a singleton class instead of a
regular function?
--
- Adam
-----
Adam Fields, Managing Partner, fields at surgam.net
Surgam, Inc. is a technology consulting firm with strong background in
delivering scalable and robust enterprise web and IT applications.
http://www.adamfields.com
More information about the talk
mailing list