added describtion for unserialize_callback_function

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@64368 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Bernd Roemer 2001-12-10 00:46:49 +00:00
parent 5ec2acf354
commit f937fa85ca

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.79 $ -->
<!-- $Revision: 1.80 $ -->
<reference id="ref.variables">
<title>Variable Functions</title>
<titleabbrev>Variables</titleabbrev>
@ -1150,16 +1150,42 @@ settype($bar, "string"); // $bar is now "1" (string)
If an object was serialized, its methods are not preserved in the
returned value.
</simpara>
<note>
<para>
In PHP 3, methods are not preserved when unserializing a
serialized object. PHP 4 removes that limitation and restores
both properties and methods. Please see the <link
linkend="language.oop.serialization">Serializing Objects</link>
section of <link linkend="language.oop">Classes and
Objects</link> or more information.
</para>
</note>
<simpara>
It's possible to set a callback-function which will be called,
if an undefined class should be instanciated during unserializing.
(to prevent getting an incomplete <type>object</type> "__PHP_Incomplete_Class".)
Use your php.ini, <function>ini_set</function> or .htaccess-file
to define 'unserialize_callback_func'.
Everytime an undefined class should be instanciated, it'll be called.
To disable this feature just empty this global variable.
<para>
<example>
<title>unserialize_callback_func example</title>
<programlisting role="php">
<![CDATA[
$serialized_object='O:1:"a":1:{s:5:"value";s:3:"100";}';
ini_set('unserialize_callback_func','mycallback'); // set your callback_function
function mycallback($classname) {
// just include a file containing your classdefinition
// you get $classname to figure out which classdefinition is required
}
]]>
</programlisting>
</example>
</para>
</simpara>
<note>
<para>
In PHP 3, methods are not preserved when unserializing a
serialized object. PHP 4 removes that limitation and restores
both properties and methods. Please see the <link
linkend="language.oop.serialization">Serializing Objects</link>
section of <link linkend="language.oop">Classes and
Objects</link> or more information.
</para>
</note>
<para>
<example>
<title><function>unserialize</function> example</title>