php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24860 register_shutdown_function param doesn't take array(obj, method)
Submitted: 2003-07-29 17:16 UTC Modified: 2003-07-29 22:39 UTC
From: tom at minnesota dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.2 OS: NetBSD/Alpha (64bit) - 1.6
Private report: No CVE-ID: None
 [2003-07-29 17:16 UTC] tom at minnesota dot com
Description:
------------
It seems like register_shutdown_function doesn't take a param of array(obj, method):

  register_shutdown_function(array(&$this, 'MyDestructor'));

---
Fails with this error:

Warning: Unknown(): Unable to call Array() - function does not exist in Unknown on line 0.

Reproduce code:
---------------
<?php
class Object {
   var $somevar = "foo";

   function Object() {
      $somevar = "bar";
      register_shutdown_function(array(&$this, 'MyDestructor'));
  }

   function MyDestructor() {
       # Do useful destructor stuff here...
   }
}

# Now create the object as follows and then 'MyDestructor'
# will be called on shutdown and will be able to operate on
# the object as it ended up... not as it started!
$my_object =& new Object;
?>


Expected result:
----------------
Pseudo destructor to perform properly with register_shutdown_function taking an array(obj, method).

Actual result:
--------------
Warning: Unknown(): Unable to call Array() - function does not exist in Unknown on line 0.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-29 19:40 UTC] pollita@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Works fine here with the exact code you pasted.  Please try the snapshot indicated above.
 [2003-07-29 22:39 UTC] tom at minnesota dot com
php4-STABLE-200307300130 worked.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 21:01:33 2025 UTC