Associate
- Joined
- 18 Oct 2002
- Posts
- 2,055
- Location
- Brighton, UK
I have a funny problem that I can't seem to get arround, when you have a error handling function within a class, registered as
Any assignments that error handler makes to the object through $this->variable don't work. Anyone got any ideas?
Code:
Output
Code:
set_error_handler(array($this, "handleerror"));
Code:
PHP:
<?php
$testObject = new rsObject("Passed");
print_r($testObject);
?>
<?php
class rsObject
{
var $sTextFromConstructor;
var $sTextFromMethod;
var $sTextFromErrorHandler;
function rsObject($sInput)
{
echo ("Constructor was called\n");
$this->sTextFromConstructor = $sInput;
$this->updatetext($sInput);
set_error_handler(array($this, "handleerror"));
mysql_connect("server", "username", "password");
restore_error_handler();
}
function updatetext($sUpdate)
{
echo ("Updatetext was called\n");
$this->sTextFromMethod = $sUpdate;
}
function handleerror($errno, $errstr, $errfile, $errline)
{
echo ("Handleerror was called\n\n");
$this->sTextFromErrorHandler = "Passed";
}
}
?>
Output
Code:
Constructor was called
Updatetext was called
Handleerror was called
rsobject Object
(
[sTextFromConstructor] => Passed
[sTextFromMethod] => Passed
[sTextFromErrorHandler] =>
)