note 60394 deleted from function.set-error-handler by cmb

From: Date: Sun, 13 Oct 2019 07:27:23 +0000
Subject: note 60394 deleted from function.set-error-handler by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212584@lists.php.net to get a copy of this message
Note Submitter: Gulopine ---- Also note that even though the documentation states "errcontext will contain an array of every variable that existed in the scope the error was triggered in," that is not the case for $this in an instantiated object, as of PHP 5.1.1. <?php function error_function($errno, $errstr, $errfile, $errline, $errcontext) { print_r($errcontext); } set_error_handler('error_function'); class test_class { private $id; function __construct($id) { $this->id = $id; trigger_error('Test error'); } } $test = new test_class(5); ?> Result: Array ( [id] => 5 ) I discovered this when trying to write an error handler that would log the class the error occured in, as it was triggered from a function in a parent class extended by several individual classes.

« previous php.notes (#212584) next »