mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
What if __sleep doesn't return anything, fix example (bug #40344)
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@232491 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
3a16879095
commit
d03f51b401
2 changed files with 13 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.66 $ -->
|
||||
<!-- $Revision: 1.67 $ -->
|
||||
<chapter id="language.oop">
|
||||
<title>Classes and Objects (PHP 4)</title>
|
||||
|
||||
|
@ -755,11 +755,12 @@ $b->example();
|
|||
being run prior to any serialization. It can clean up the object
|
||||
and is supposed to return an array with the names of all variables
|
||||
of that object that should be serialized.
|
||||
If the method doesn't return anything then &null; is serialized and
|
||||
E_NOTICE is issued.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The intended use of <literal>__sleep</literal> is to close any
|
||||
database connections that object may have, committing pending
|
||||
The intended use of <literal>__sleep</literal> is to commit pending
|
||||
data or perform similar cleanup tasks. Also, the function is
|
||||
useful if you have very large objects which need not be
|
||||
saved completely.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<!-- $Revision: 1.14 $ -->
|
||||
<sect1 id="language.oop5.magic">
|
||||
<title>Magic Methods</title>
|
||||
<para>
|
||||
|
@ -41,14 +41,19 @@
|
|||
executed prior to any serialization. It can clean up the object
|
||||
and is supposed to return an array with the names of all variables
|
||||
of that object that should be serialized.
|
||||
If the method doesn't return anything then &null; is serialized and
|
||||
E_NOTICE is issued.
|
||||
</para>
|
||||
<para>
|
||||
The intended use of <literal>__sleep</literal> is to close any
|
||||
database connections that the object may have, commit pending
|
||||
The intended use of <literal>__sleep</literal> is to commit pending
|
||||
data or perform similar cleanup tasks. Also, the function is
|
||||
useful if you have very large objects which do not need to be
|
||||
saved completely.
|
||||
</para>
|
||||
<para>
|
||||
The <literal>__sleep</literal> method should return the value to serialize
|
||||
(usually <literal>$this</literal>), otherwise &null; is serialized.
|
||||
</para>
|
||||
<para>
|
||||
Conversely, <function>unserialize</function> checks for the
|
||||
presence of a function with the magic name
|
||||
|
@ -87,7 +92,7 @@ class Connection {
|
|||
|
||||
public function __sleep()
|
||||
{
|
||||
mysql_close($this->link);
|
||||
return array('server', 'username', 'password', 'db');
|
||||
}
|
||||
|
||||
public function __wakeup()
|
||||
|
|
Loading…
Reference in a new issue