note 75214 deleted from language.oop5.magic by nlopess
| From: | nlopess@php.net | Date: | Sun, 20 May 2007 13:50:16 +0000 |
| Subject: | note 75214 deleted from language.oop5.magic by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126746@lists.php.net to get a copy of this message | ||
Note Submitter: Andrea Giammarchi
----
I wonder why "Magic" should disappear in this case:
<?php
class DynamicFunction {
private $callback;
function __construct(){
$this->callback = create_function('', 'return "Hello
World!";');
}
function __toString(){
return ''.$this->callback;
}
}
$f = new DynamicFunction();
$s = ''.$f;
echo $s(); // Hello World!
echo $f(); // Fatal Error ...
?>
... it "shouldn't be useful", but why Fatal Error?!?!?!????
Parser should read __toString value and use them as expected (at least in my humil opinion).