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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 01 13:01:33 2024 UTC