|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-08-18 09:22 UTC] auroraeosrose at hotmail dot com
Description:
------------
Latest cvs snapshot of 4.3.whatever we're at now. When sending an object/method array for a set_error_handler, the object is not being referenced, I have no idea what it's doing.
I'd like to be able to change stuff in the object I have the error handler in before an error is triggered...
This may be a dupe of #22894 but I'm not sure since that one wasn't explained very well...
Reproduce code:
---------------
<?
class Stack
{
var $stack;
function Stack()
{
$this->stack = array();
set_error_handler(array(&$this, 'errorHandler'));
}
function push($message)
{
$this->stack[] = $message;
print_r($this); //for debugging
}
function errorHandler($code, $message, $file, $line, $context)
{
$this->push($message);
}
}
$e = new Stack();
$e->push('This is a fun test');
trigger_error('This is a test', E_USER_NOTICE);
?>
Expected result:
----------------
stack Object
(
[stack] => Array
(
[0] => This is a fun test
)
)
stack Object
(
[stack] => Array
(
[0] => This is fun a test
[1] => This is a test
)
)
Actual result:
--------------
stack Object
(
[stack] => Array
(
[0] => This is a fun test
)
)
stack Object
(
[stack] => Array
(
[0] => This is a test
)
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 10:00:01 2025 UTC |
You're missing the point, I want to send a referenced object and be able to change things it before I trigger an error...another test <? class Stack { var $stack; var $debug; function Stack() { $this->stack = array(); $this->debug = false; set_error_handler(array(&$this, 'errorHandler')); } function push($message) { $this->stack[] = $message; print_r($this); //for debugging } function errorHandler($code, $message, $file, $line, $context) { $this->push($message); } } $e = new Stack(); $e->debug = true; trigger_error('This is a test', E_USER_NOTICE); ?> Now, notice I've changed debug before I triggered the error, so when I do my print_r of $this it should have debug set to true, because I changed it, but notice it's still set to false