note 111981 added to language.oop5.magic
| From: | igorbt | Date: | Thu, 18 Apr 2013 20:30:30 +0000 |
| Subject: | note 111981 added to language.oop5.magic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194546@lists.php.net to get a copy of this message | ||
In recent versions of PHP, if you define __toString with arguments it will trigger a Fatal error:
"__tostring() cannot take arguments". But, if you really need this (like I needed, because
my framework heavily used these arguments), you have a workaround:
<?php
class a
{
public function __toString() {
list($a) = func_get_args();
return $a;
}
}
$a = new a();
echo $a->__toString('PHP'); // PHP
?>
----
Server IP: 69.147.83.199
Probable Submitter: 78.97.147.124
----
Manual Page -- http://php.net/manual/en/language.oop5.magic.php
Edit -- https://master.php.net/note/edit/111981
Del: integrated -- https://master.php.net/note/delete/111981/integrated
Del: useless -- https://master.php.net/note/delete/111981/useless
Del: bad code -- https://master.php.net/note/delete/111981/bad+code
Del: spam -- https://master.php.net/note/delete/111981/spam
Del: non-english -- https://master.php.net/note/delete/111981/non-english
Del: in docs -- https://master.php.net/note/delete/111981/in+docs
Del: other reasons-- https://master.php.net/note/delete/111981
Reject -- https://master.php.net/note/reject/111981
Search -- https://master.php.net/manage/user-notes.php