You are here: Re: Shutdown order « PHP Programming Language « IT news, forums, messages
Re: Shutdown order

Posted by mannerboy on 11/17/06 05:52

maybe i guess , once overload the function __destruct() , you should
destruct the object explicitly...

i havn't written a script to test this .....


"Thomas Mlynarczyk 写道:
"
> Hi,
>
> I have this code:
>
> class Test
> {
> public $status = 'dead';
> function __construct() { $this->status = 'alive'; }
> function __destruct() { echo '<br>__destruct()'; }
> }
> $o = new Test;
>
> function shutdown()
> {
> echo '<br>shutdown()';
> }
> register_shutdown_function('shutdown');
>
> function obflush( $s )
> {
> global $o;
> return $s . '<br>obflush() ' . $o->status;
> }
> ob_start('obflush');
>
> Which (using PHP 5.1.4) produces this output:
>
> shutdown()
> __destruct()
> obflush() alive
>
> I have two questions:
>
> 1) I have read that the order in which the three functions are called has
> changed previously and is likely to change again in future versions of PHP.
> Does this mean I cannot rely on this order at all?
>
> 2) Why is $o still "alive" in obflush() even though its destructor has been
> called before? The destructor having been called, I would expect global $o
> to point to a no longer existing variable (thus, "null").
>
> Greetings,
> Thomas

 

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

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