php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34528 strange destructor behavior
Submitted: 2005-09-16 16:39 UTC Modified: 2005-09-16 16:46 UTC
From: silencer at reignofwar dot de Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.5 OS: Ubuntu 5.10 (Linux 2.6.12)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: silencer at reignofwar dot de
New email:
PHP Version: OS:

 

 [2005-09-16 16:39 UTC] silencer at reignofwar dot de
Description:
------------
Only look at the code and the output of it. I think, new 
objects in variables, which are already existent and 
contain an old object, should be call the destructor of 
the old object... im sorry for my english... 

Reproduce code:
---------------
<?php
class test {
	static $i = 0;
	
	public function __construct() {
		self::$i ++;
		echo "alive: " . self::$i . "<br />";
	}
	public function __destruct() {
		echo "dead" . self::$i . "<br />";
	}
}

$obj = new test;
$obj = new test;
?>

Expected result:
----------------
alive: 1 
dead1 
alive: 2 
dead2 

Actual result:
--------------
alive: 1 
alive: 2 
dead2 
dead2 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-16 16:46 UTC] sniper@php.net
__construct() call are always run before __destruct(). Latter being done during request shutdown. No bug here.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 15:01:33 2025 UTC