You are here: Re: _sleep and _wakeup « PHP Programming Language « IT news, forums, messages
Re: _sleep and _wakeup

Posted by AlexVN on 10/07/88 11:50

Water Cooler v2 wrote:
> I didn't understand from this
>
> http://in2.php.net/manual/en/language.oop.magic-functions.php
>
> whether we, the programmer, have to implement _sleep and _wakeup (like
> .NET's IDisposable.Dispose()) or it is done by PHP internally on a
> class that uses resources?

Hi,

__sleep and __wakeup are the methods, that you can implement in your
class. They are just like events that occur before serialization and
after unserialization. Consider this:

class MyClass {
function __sleep() {
echo "__sleep\n";
return array();
}
function __wakeup() {
echo "__wakeup\n";
}
}

$c = new MyClass();
echo "Sleep: ";
$str = serialize($c);
echo "Wakeup: ";
$c1 = unserialize($str);

The output will be:
Sleep: __sleep
Wakeup: __wakeup

Sincerely,
Alexander
http://www.alexatnet.com/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация