note 37459 added to function.set-error-handler
| From: | phpmanual at NO_SPHAMnetebb dot com | Date: | Sun, 16 Nov 2003 01:19:16 +0000 |
| Subject: | note 37459 added to function.set-error-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-60444@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 set_error_handler() as an
example):
1: set_error_handler('NonClassFunction');
2: set_error_handler(array('CallbackClass', 'StaticFunction'));
3: $o =& new CallbackClass();
set_error_handler(array($o, 'CallbackFunction'));
The following may also prove useful:
class CallbackClass {
function CallbackClass() {
set_error_handler(array(&$this, 'CallbackFunction')); // the & is important
}
function CallbackFunction() {
// refers to $this
}
}
The documentation is not clear in outlining these three examples.
----
Manual Page -- http://www.php.net/manual/en/function.set-error-handler.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37459
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37459&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37459&report=yes
Search -- http://master.php.net/manage/user-notes.php