#31326 [Opn->Fbk]: Object Destruction Order
| From: | sniper@php.net | Date: | Mon, 28 Feb 2005 20:05:52 +0000 |
| Subject: | #31326 [Opn->Fbk]: Object Destruction Order | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-76885@lists.php.net to get a copy of this message | ||
ID: 31326
Updated by: sniper@php.net
Reported By: sir dot gallahad at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: Zend Engine 2 problem
Operating System: Linux
PHP Version: 5.0.2
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2004-12-28 20:27:18] sir dot gallahad at gmail dot com
Description:
------------
First of all. It's not a bug. It's a sugestion to give more stability
to the engine.
When the Zend Engine reaches the end of a script page it cleans up the
classes that have been created.
Nowadays it cleans up in the order the classes have been created.
I suggest that it would be a safer routine to destroy a class following
a heap of objects (first in last out).
It would help some nesting routines, not mentioning the memory
allocation.
Reproduce code:
---------------
<?
$ident = 0;
class Tag {
public $aVar;
function __construct( $pMe ) {
global $ident;
$this->aVar = $pMe;
echo
str_repeat(" ",$ident)."[".$this->aVar."]<br>";
$ident++;
}
function __destruct() {
global $ident;
$ident--;
echo
str_repeat(" ",$ident)."[/".$this->aVar."]<br>";
}
}
$v1 = new Tag("tag1");
$v2 = new Tag("tag2");
$v3 = new Tag("tag3");
echo '<br><br>';
?>
Expected result:
----------------
[tag1]
[tag2]
[tag3]
[/tag3]
[/tag2]
[/tag1]
Actual result:
--------------
[tag1]
[tag2]
[tag3]
[/tag1]
[/tag2]
[/tag3]
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31326&edit=1