Some clarifications on unserialize()

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@75937 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Gabor Hojtsy 2002-03-30 16:48:55 +00:00
parent c87365d8d9
commit 0d51567bb7

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.101 $ -->
<!-- $Revision: 1.102 $ -->
<reference id="ref.variables">
<title>Variable Functions</title>
<titleabbrev>Variables</titleabbrev>
@ -1133,8 +1133,6 @@ settype($bar, "string"); // $bar is now "1" (string)
back into a PHP value. The converted value is returned, and can
be an <type>integer</type>, <type>float</type>,
<type>string</type>, <type>array</type> or <type>object</type>.
If an object was serialized, its methods are not preserved in the
returned value.
</simpara>
<note>
<para>
@ -1144,7 +1142,7 @@ settype($bar, "string"); // $bar is now "1" (string)
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.
To disable this feature just empty this setting.
</para>
</note>
<para>
@ -1179,9 +1177,9 @@ function mycallback($classname) {
<title><function>unserialize</function> example</title>
<programlisting role="php">
<![CDATA[
// Here, we use unserialize() to load session data from a database
// into $session_data. This example complements the one described
// with <function>serialize</function>.
// Here, we use unserialize() to load session data to the
// $session_data array from the string selected from a database.
// This example complements the one described with serialize().
$conn = odbc_connect ("webdb", "php", "chicken");
$stmt = odbc_prepare ($conn, "SELECT data FROM sessions WHERE id = ?");
@ -1193,8 +1191,8 @@ if (!odbc_execute ($stmt, &$sqldata) || !odbc_fetch_into ($stmt, &$tmp)) {
// we should now have the serialized data in $tmp[0].
$session_data = unserialize ($tmp[0]);
if (!is_array ($session_data)) {
// something went wrong, initialize to empty array
$session_data = array();
// something went wrong, initialize to empty array
$session_data = array();
}
}
]]>