Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > fedef0ce54a3761fc1862157672b700c > files > 3757

php-manual-ar-5.1.6-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>The magic functions __sleep and __wakeup</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Handleiding"
HREF="index.html"><LINK
REL="UP"
TITLE="Classes and Objects (PHP 4)"
HREF="language.oop.html"><LINK
REL="PREVIOUS"
TITLE="Serializing objects - objects in sessions"
HREF="language.oop.serialization.html"><LINK
REL="NEXT"
TITLE="References inside the constructor"
HREF="language.oop.newref.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Handleiding</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="language.oop.serialization.html"
ACCESSKEY="P"
>Terug</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Hoofdstuk 13. Classes and Objects (PHP 4)</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="language.oop.newref.html"
ACCESSKEY="N"
>Volgende</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="language.oop.magic-functions"
>The magic functions <VAR
CLASS="literal"
>__sleep</VAR
> and <VAR
CLASS="literal"
>__wakeup</VAR
></A
></H1
><P
>&#13;   <A
HREF="function.serialize.html"
><B
CLASS="function"
>serialize()</B
></A
> checks if your class has a function with
   the magic name <VAR
CLASS="literal"
>__sleep</VAR
>. If so, that function is
   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.
  </P
><P
>&#13;   The intended use of <VAR
CLASS="literal"
>__sleep</VAR
> is to close any
   database connections that object may have, committing pending
   data or perform similar cleanup tasks. Also, the function is
   useful if you have very large objects which need not be
   saved completely.
  </P
><P
>&#13;   Conversely, <A
HREF="function.unserialize.html"
><B
CLASS="function"
>unserialize()</B
></A
> checks for the
   presence of a function with the magic name 
   <VAR
CLASS="literal"
>__wakeup</VAR
>. If present, this function can
   reconstruct any resources that object may have.
  </P
><P
>&#13;    The intended use of <VAR
CLASS="literal"
>__wakeup</VAR
> is to
    reestablish any database connections that may have been lost
    during serialization and perform other reinitialization
    tasks.
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="language.oop.serialization.html"
ACCESSKEY="P"
>Terug</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Begin</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="language.oop.newref.html"
ACCESSKEY="N"
>Volgende</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Serializing objects - objects in sessions</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="language.oop.html"
ACCESSKEY="U"
>Omhoog</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>References inside the constructor</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>