Bug #15791 Updated: set_error_handler() can not be used to set error control to a class function
| From: | cox@php.net | Date: | Thu, 13 Jun 2002 00:52:46 +0000 |
| Subject: | Bug #15791 Updated: set_error_handler() can not be used to set error control to a class function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-10294@lists.php.net to get a copy of this message | ||
ID: 15791
Updated by: cox@php.net
Reported By: ned@wgtech.com
-Status: Analyzed
+Status: Duplicate
Bug Type: Feature/Change Request
Operating System: All
PHP Version: 4.1.1
New Comment:
http://bugs.php.net/bug.php?id=9155
Previous Comments:
------------------------------------------------------------------------
[2002-02-28 17:38:35] mfischer@php.net
This request is valid (it's a limitation of the current implementation
in zend_builtin_functions.c) but your analysis wasn't very accurat.
Methods of Static Classes or objects are normally passed with the
syntax array($obj, 'method'); or array('class', 'method');
Anyway, it's an open feature request.
------------------------------------------------------------------------
[2002-02-28 14:26:17] ned@wgtech.com
Heres the long and short of it: set_error_handler() wants a string as
the name of the function that will handle errors. However, if you
create a class and try to assign error handling to a function within
the class, there is no way to reference that function.
For example
class ApplicationObject {
var $error_List as array();
function ApplicationObject() {
set_error_handler('trapError');
}
function trapError($err_no, $err_str, $err_file, $err_line,
$err_context) {
echo "Trap error caught error ".$err_no;
}
}
// *** Now create the object ***
$app = new ApplicationObject();
trigger_error ("Cannot divide by zero", E_USER_ERROR);
This doesn't work. Nor does changing set_error_handler('trapError') to
set_error_handler('$this->trapError'). Removing the quotes just
executes the function. Removing the assignment of error handling
outside of the class like so:
$app = new ApplicationObject();
set_error_handler('$app->trapError');
trigger_error ("Cannot divide by zero", E_USER_ERROR);
Since the error handling function will need access to $error_List and I
sure dont want to GLOBAL it, this kind of makes things difficult.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=15791&edit=1