П О Р Т А Л                            
С Е Т Е В Ы Х                          
П Р О Е К Т О В                        
  
Поиск по сайту:
                                                 
Главная

О проекте

Web-мастеру
     HTML & JavaScript
     SSI
     Perl
     PHP
     XML & XSLT
     Unix Shell

MySQL

Безопасность

Хостинг

Другое








Самое читаемое:

Учебник PHP - "Для Чайника".
Просмотров 187240 раз(а).

Иллюстрированный самоучитель по созданию сайтов.
Просмотров 89722 раз(а).

Учебник HTML.
Просмотров 80442 раз(а).

Руководство по PHP5.
Просмотров 50832 раз(а).

Хостинг через призму DNS.
Просмотров 58715 раз(а).

Подборка текстов стандартных документов.
Просмотров 49643 раз(а).

Учебник PHP - Самоучитель
Просмотров 56901 раз(а).

Документация на MySQL (учебник & справочное руководство)
Просмотров 58229 раз(а).

Внешние атаки...
Просмотров 47609 раз(а).

Учебник PHP.
Просмотров 41590 раз(а).

SSI в примерах.
Просмотров 31860 раз(а).



 
 
| Добавить в избранное | Сделать стартовой | Помощь





Руководство по PHP
Пред. След.

unserialize

(PHP 3 >= 3.0.5, PHP 4, PHP 5)

unserialize --  Creates a PHP value from a stored representation

Description

mixed unserialize ( string str )

unserialize() takes a single serialized variable (see serialize()) and converts it back into a PHP value. The converted value is returned, and can be a boolean, integer, float, string, array or object. In case the passed string is not unserializeable, FALSE is returned and E_NOTICE is issued.

Внимание

FALSE is returned both in the case of an error and if unserializing the serialized FALSE value. This special case can be catched by comparing str with serialize(false) or by catching the issued E_NOTICE.

unserialize_callback_func directive: It's possible to set a callback-function which will be called, if an undefined class should be instantiated during unserializing. (to prevent getting an incomplete object "__PHP_Incomplete_Class".) Use your php.ini, ini_set() or .htaccess to define 'unserialize_callback_func'. Everytime an undefined class should be instantiated, it'll be called. To disable this feature just empty this setting. Also note that the directive unserialize_callback_func directive became available in PHP 4.2.0.

If the variable being unserialized is an object, after successfully reconstructing the object PHP will automatically attempt to call the __wakeup() member function (if it exists).

Пример 1. unserialize_callback_func example

<?php
$serialized_object
='O:1:"a":1:{s:5:"value";s:3:"100";}';

// unserialize_callback_func directive available as of PHP 4.2.0
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
}
?>

Замечание: In PHP 3, methods are not preserved when unserializing a serialized object. That limitation was removed in PHP 4 as both properties and methods are now restored. Please see the Serializing Objects section of Classes and Objects or more information.

Пример 2. unserialize() example

<?php
// 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 = ?");
$sqldata = array ($PHP_AUTH_USER);
if (!
odbc_execute($stmt, &$sqldata) || !odbc_fetch_into($stmt, &$tmp)) {
    
// if the execute or fetch fails, initialize to empty array
    
$session_data = array();
} else {
    
// 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();
    }
}
?>

See also serialize().



Если Вы не нашли что искали, то рекомендую воспользоваться поиском по сайту:
 





Copyright © 2005-2016 Project.Net.Ru