cvs: phpdoc-zh /reference/var/functions unserialize.xml

From: Date: Sat, 14 Jun 2003 13:31:54 +0000
Subject: cvs: phpdoc-zh /reference/var/functions unserialize.xml
Groups: php.doc.zh 
Request: Send a blank email to doc-zh+get-1508@lists.php.net to get a copy of this message
nio Sat Jun 14 09:31:54 2003 EDT Added files: /phpdoc-zh/reference/var/functions unserialize.xml Log: Add file Index: phpdoc-zh/reference/var/functions/unserialize.xml +++ phpdoc-zh/reference/var/functions/unserialize.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: nio $ --> <!-- EN-Revision: 1.12 Maintainer: nio Status: ready --> <!-- splitted from ./en/functions/var.xml, last change in rev 1.2 --> <refentry id="function.unserialize"> <refnamediv> <refname>unserialize</refname> <refpurpose> ´ÓÒÑ´æ´¢µÄ±íʾÖд´½¨ PHP µÄÖµ </refpurpose> </refnamediv> <refsect1> <title>ÃèÊö</title> <methodsynopsis> <type>mixed</type><methodname>unserialize</methodname> <methodparam><type>string</type><parameter>str</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>callback</parameter></methodparam> </methodsynopsis> <simpara> <function>unserialize</function> ¶Ôµ¥Ò»µÄÒÑÐòÁл¯µÄ±äÁ¿½øÐвÙ×÷£¬½«Æäת»»»Ø PHP µÄÖµ¡£·µ»ØµÄÊÇת»»Ö®ºóµÄÖµ£¬¿ÉΪ <type>integer</type>¡¢<type>float</type>¡¢<type>string</type>¡¢<type>array</type> »ò <type>object</type>¡£Èç¹û´«µÝµÄ×Ö·û´®²»¿É½âÐòÁл¯£¬Ôò·µ»Ø &false;¡£ </simpara> <note> <title>unserialize_callback_func Ö¸Áî</title> <para> Èç¹ûÔÚ½âÐòÁл¯µÄʱºòÐèҪʵÀý»¯Ò»¸ö䶨ÒåÀ࣬Ôò¿ÉÒÔÉèÖûص÷º¯ÊýÒÔ¹©µ÷Óã¨ÒÔÃâµÃµ½µÄÊDz»ÍêÕûµÄ <type>object</type> ¡°__PHP_Incomplete_Class¡±£©¡£¿Éͨ¹ý &php.ini;¡¢<function>ini_set</function> »ò &htaccess; ¶¨Òå¡®unserialize_callback_func¡¯¡£Ã¿´ÎʵÀý»¯Ò»¸ö䶨ÒåÀàʱËü¶¼»á±»µ÷Óá£ÈôÒª½ûÖ¹Õâ¸öÌØÐÔ£¬Ö»ÐèÖÿմËÉ趨¡£»¹ÐèҪעÒâµÄÊÇ unserialize_callback_func Ö¸ÁîÊÇ´Ó PHP 4.2.0 ¿ªÊ¼ÌṩʹÓõġ£ </para> </note> <note> <para> <parameter>callback</parameter> ²ÎÊýÊÇÔÚ PHP 4.2.0 ÖÐÌí¼ÓµÄ </para> </note> <para> Èô±»½âÐòÁл¯µÄ±äÁ¿ÊÇÒ»¸ö¶ÔÏó£¬Ôڳɹ¦µØÖØÐ¹¹Ôì¶ÔÏóÖ®ºó£¬PHP »á×Ô¶¯µØÊÔͼȥµ÷Óà <function>__wakeup</function> ³ÉÔ±º¯Êý£¨Èç¹û´æÔڵϰ£©¡£ <example> <title>unserialize_callback_func ʾÀý</title> <programlisting role="php"> <![CDATA[ <?php $serialized_object='O:1:"a":1:{s:5:"value";s:3:"100";}'; // unserialize_callback_func ´Ó PHP 4.2.0 Æð¿ÉÓà ini_set('unserialize_callback_func','mycallback'); // ÉèÖÃÄúµÄ»Øµ÷º¯Êý function mycallback($classname) { // Ö»Ðè°üº¬º¬ÓÐÀඨÒåµÄÎļþ // $classname Ö¸³öÐèÒªµÄÊÇÄÄÒ»¸öÀà } ?> ]]> </programlisting> </example> </para> <note> <para> ÔÚ PHP 3 ÖУ¬½âÐòÁл¯Ò»¸ö¶ÔÏóʱÊDz»±£´æ·½·¨µÄ¡£¶ø PHP 4 ´òÆÆÁËÕâ¸öÏÞÖÆ£¬Í¬Ê±±£´æÁËÊôÐԺͷ½·¨¡£Çë²Î¼û<link linkend="language.oop">ÀàÓë¶ÔÏó</link>ÖеÄ<link linkend="language.oop.serialization">ÐòÁл¯¶ÔÏó</link>²¿·Ö»ñÈ¡¸ü¶àÐÅÏ¢¡£ </para> </note> <para> <example> <title><function>unserialize</function> ʾÀý</title> <programlisting role="php"> <![CDATA[ <?php // ÕâÀÎÒÃÇʹÓà unserialize() ×°ÔØÀ´×ÔÊý¾Ý¿âµÄ $session_data Êý×éÖеĻỰÊý¾Ý¡£ // ´ËÀýÊÇÃèÊö serialize() µÄÄǸöÀý×ӵIJ¹³ä¡£ $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)) { // Èç¹ûÖ´Ðгö´í»ò·µ»Ø´íÎó£¬Ôò³õʼ»¯Îª¿ÕÊý×é $session_data = array(); } else { // ÏÖÔÚÎÒÃÇÐèÒªµÄÊÇ $tmp[0] ÖÐÒÑÐòÁл¯µÄÊý¾Ý¡£ $session_data = unserialize ($tmp[0]); if (!is_array ($session_data)) { // ³ö´í£¬³õʼ»¯Îª¿ÕÊý×é $session_data = array(); } } ?> ]]> </programlisting> </example> </para> <para> ²Î¼û <function>serialize</function>¡£ </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->

« previous php.doc.zh (#1508) next »