Hi all,
I have a class with the methods __toString and __get and some protected properties such as "message". So far, so good.
The problem now is that I need to access $this->message in __toString, and this causes (NOT ALWAYS BUT OFTEN) a segmentation fault when (see following example) $display_all is set to true. Do you know why and how to fix it ?
Thanks a lot ! Rolf
PS: here is an example
class FuckedClass {
protected $file;
protected $line;
protected $display_all;
protected $message;
//[...]
/**
* Magic getter
* @param String $name
* @return mixed
*/
public function __get($name) {
return (in_array($name,array_keys(get_class_vars(__CLASS__))))?
$this->$name : null;
}
/**
* Formats
*/
public function __toString() {
$message = $this->message . ($this->display_all) ?
'[ Location: '.$this->file.' @ line '.$this->line.' ]':
'';
$text =<<<PLAIN
Error : {$message}
PLAIN;
return $text;
}
}
//instantiated $fucked_class
die($fucked_class);