note 37460 added to function.register-shutdown-function

From: Date: Sun, 16 Nov 2003 01:31:23 +0000
Subject: note 37460 added to function.register-shutdown-function
Groups: php.notes 
Request: Send a blank email to php-notes+get-60445@lists.php.net to get a copy of this message
Given this code: class CallbackClass { function CallbackFunction() { // refers to $this } function StaticFunction() { // doesn't refer to $this } } function NonClassFunction() { } there appear to be 3 ways to set a callback function in PHP (using register_shutdown_function() as an example): 1: register_shutdown_function('NonClassFunction'); 2: register_shutdown_function(array('CallbackClass', 'StaticFunction')); 3: $o =& new CallbackClass(); register_shutdown_function(array($o, 'CallbackFunction')); The following may also prove useful: class CallbackClass { function CallbackClass() { register_shutdown_function(array(&$this, 'CallbackFunction')); // the & is important } function CallbackFunction() { // refers to $this } } ---- Manual Page -- http://www.php.net/manual/en/function.register-shutdown-function.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37460 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37460&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37460&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60445) next »