From 0d51567bb79ebe573bb6e23824da99c104d6d749 Mon Sep 17 00:00:00 2001 From: Gabor Hojtsy Date: Sat, 30 Mar 2002 16:48:55 +0000 Subject: [PATCH] Some clarifications on unserialize() git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@75937 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/var.xml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/functions/var.xml b/functions/var.xml index f44070b145..155a02f862 100644 --- a/functions/var.xml +++ b/functions/var.xml @@ -1,5 +1,5 @@ - + Variable Functions Variables @@ -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 integer, float, string, array or object. - If an object was serialized, its methods are not preserved in the - returned value. @@ -1144,7 +1142,7 @@ settype($bar, "string"); // $bar is now "1" (string) Use your &php.ini;, ini_set 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. @@ -1179,9 +1177,9 @@ function mycallback($classname) { <function>unserialize</function> example serialize. +// 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(); } } ]]>