note 81471 added to language.oop5.overloading
| From: | MattCreenan at osu1 dot php dot net | Date: | Fri, 29 Feb 2008 16:34:16 +0000 |
| Subject: | note 81471 added to language.oop5.overloading | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136597@lists.php.net to get a copy of this message | ||
PHP4 supports using __call but with a twist that I did not see mentioned anywhere on this page.
In 4, you must make the __call method signature with 3 parameters, the 3rd of which is the return
value and must be declared by-reference. Instead of using "return $value;" you would
assign the 3rd argument to $value.
Example (both implementations below have the same result when run in the respective PHP versions:
<?php
// Will only work in PHP4
class Foo
{
function __call($method_name, $parameters, &$return_value)
{
$return_value = "Method $method_name was called with " . count($parameters) . "
parameters";
}
}
// Will only work in PHP5
class Foo
{
function __call($method_name, $parameters)
{
return "Method $method_name was called with " . count($parameters) . "
parameters";
}
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 64.8.70.20
----
Manual Page -- http://www.php.net/manual/en/language.oop5.overloading.php
Edit -- https://master.php.net/note/edit/81471
Del: integrated -- https://master.php.net/note/delete/81471/integrated
Del: useless -- https://master.php.net/note/delete/81471/useless
Del: bad code -- https://master.php.net/note/delete/81471/bad+code
Del: spam -- https://master.php.net/note/delete/81471/spam
Del: non-english -- https://master.php.net/note/delete/81471/non-english
Del: in docs -- https://master.php.net/note/delete/81471/in+docs
Del: other reasons-- https://master.php.net/note/delete/81471
Reject -- https://master.php.net/note/reject/81471
Search -- https://master.php.net/manage/user-notes.php