php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36339 register_shutdown_function and &$this
Submitted: 2006-02-09 14:23 UTC Modified: 2006-02-09 14:37 UTC
From: ni dot ki dot ta at mail dot ru Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.4.2 OS: Linux
Private report: No CVE-ID: None
 [2006-02-09 14:23 UTC] ni dot ki dot ta at mail dot ru
Description:
------------
Is it possible to use register_shutdown_function(array(&$this,"Destructor")) inside other function?

Reproduce code:
---------------
class A {
	var $val = "A";

	function A() {
		register_shutdown_function(array(&$this,"Destructor"));
			$this->val = "B";
		}

		function Destructor() {
			print $this->val;
			print $GLOBALS["obj"]->val;
		}
	}

	$obj = new A;
	$obj->val = "C";

Expected result:
----------------
CC

Actual result:
--------------
BC

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-09 14:37 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

In PHP4 you have to use $obj = &new A; to prevent objects from copying.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 20:00:02 2026 UTC