note 41108 deleted from function.set-error-handler by cmb
| From: | cmb@php.net | Date: | Sun, 25 Aug 2019 09:01:43 +0000 |
| Subject: | note 41108 deleted from function.set-error-handler by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211992@lists.php.net to get a copy of this message | ||
Note Submitter: sijmen at digitized dot nl
----
@skyrl at free dot fr
It seems that the reference operator '&' doesn't have any effect. That's why
I submitted the comment.
<?php
class error {
var $error;
function error() {
$this->setIni();
}
function handler() {
echo $this->error.'!!';
}
function setText($text) {
$this->error = $text;
}
function setIni() {
set_error_handler(array(&$this, 'handler')); // The '&' operator
doesn't have any effect
}
}
$eh = new error;
$eh->setText('Error! <br>'); // Will not get set
trigger_error('text', E_USER_ERROR); // prints '!!'
?>
Proof of concept
http://trouby.digitized.nl/set_error_handler.php
http://trouby.digitized.nl/set_error_handler.php?source=1