reference/var/functions/serialize.xml
8cdc6621f9826d04abc3e50438c010804d7e8683
...
...
@@ -34,18 +34,20 @@
34
34
<listitem>
35
35
<para>
36
36
The value to be serialized. <function>serialize</function>
37
-
handles all types, except the <type>resource</type>-type.
37
+
handles all types, except the <type>resource</type>-type and some <type>object</type>s (see note below).
38
38
You can even <function>serialize</function> arrays that contain
39
39
references to itself. Circular references inside the array/object you
40
40
are serializing will also be stored. Any other
41
41
reference will be lost.
42
42
</para>
43
43
<para>
44
-
When serializing objects, PHP will attempt to call the member function
44
+
When serializing objects, PHP will attempt to call the member functions
45
+
<link linkend="object.serialize">__serialize()</link> or
45
46
<link linkend="object.sleep">__sleep()</link> prior to serialization.
46
47
This is to allow the object to do any last minute clean-up, etc. prior
47
48
to being serialized. Likewise, when the object is restored using
48
-
<function>unserialize</function> the <link linkend="object.wakeup">__wakeup()</link> member function is called.
49
+
<function>unserialize</function> the <link linkend="object.unserialize">__unserialize()</link> or
50
+
<link linkend="object.wakeup">__wakeup()</link> member function is called.
49
51
</para>
50
52
<note>
51
53
<para>
...
...
@@ -93,7 +95,7 @@ $sqldata = array (serialize($session_data), $_SERVER['PHP_AUTH_USER']);
93
95
if (!odbc_execute($stmt, $sqldata)) {
94
96
$stmt = odbc_prepare($conn,
95
97
"INSERT INTO sessions (id, data) VALUES(?, ?)");
96
-
if (!odbc_execute($stmt, $sqldata)) {
98
+
if (!odbc_execute($stmt, array_reverse($sqldata))) {
97
99
/* Something went wrong.. */
98
100
}
99
101
}
...
...
@@ -110,20 +112,19 @@ if (!odbc_execute($stmt, $sqldata)) {
110
112
<para>
111
113
Note that many built-in PHP objects cannot be serialized. However, those with
112
114
this ability either implement the <interfacename>Serializable</interfacename> interface or the
113
-
magic <link linkend="object.sleep">__sleep()</link> and
114
-
<link linkend="object.wakeup">__wakeup()</link> methods. If an
115
+
magic <link linkend="object.serialize">__serialize()</link>/<link linkend="object.unserialize">__unserialize()</link>
116
+
or <link linkend="object.sleep">__sleep()</link>/<link linkend="object.wakeup">__wakeup()</link> methods. If an
115
117
internal class does not fulfill any of those requirements, it cannot reliably be
116
118
serialized.
117
119
</para>
118
120
<para>
119
121
There are some historical exceptions to the above rule, where some internal objects
120
-
could be serialized without implementing the interface or exposing the methods. Notably,
121
-
the <classname>ArrayObject</classname> prior to PHP 5.2.0.
122
+
could be serialized without implementing the interface or exposing the methods.
122
123
</para>
123
124
</note>
124
125
<warning>
125
126
<para>
126
-
When <function>serialize</function> serializes objects, the leading slash is not included in the class name of namespaced classes for maximum compatibility.
127
+
When <function>serialize</function> serializes objects, the leading backslash is not included in the class name of namespaced classes for maximum compatibility.
127
128
</para>
128
129
</warning>
129
130
</refsect1>
...
...
@@ -138,6 +139,8 @@ if (!odbc_execute($stmt, $sqldata)) {
138
139
<member><link linkend="language.oop5.serialization">Serializing Objects</link></member>
139
140
<member><link linkend="object.sleep">__sleep()</link></member>
140
141
<member><link linkend="object.wakeup">__wakeup()</link></member>
142
+
<member><link linkend="object.serialize">__serialize()</link></member>
143
+
<member><link linkend="object.unserialize">__unserialize()</link></member>
141
144
</simplelist>
142
145
</para>
143
146
</refsect1>
144
147