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_shutdo wn_function('sh utdown');
function obflush( $s )
{
global $o;
return $s . '<br>obflush() ' . $o->status;
}
ob_start('obflu sh');
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
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_shutdo wn_function('sh utdown');
function obflush( $s )
{
global $o;
return $s . '<br>obflush() ' . $o->status;
}
ob_start('obflu sh');
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
Comment