Re: Re: PHP5: __call() implementation EXAMPLE
| From: | Vivian Steller | Date: | Thu, 05 Feb 2004 15:56:28 +0000 |
| Subject: | Re: Re: PHP5: __call() implementation EXAMPLE | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176904@lists.php.net to get a copy of this message | ||
John W. Holmes wrote:
> From: "Vivian Steller" <news@eecoo.de>
>
>> Vivian Steller wrote:
>>
...
>> <pre>
>> <?php
>> class MyClass {
>> function __call($method, $params) {
>> // $params = Array(mixed var, mixed var, ...);
>> print("request for " . $method . "()\n");
>>
>> // how to get objects in this string?!
>> // do i have to implement "switch($type) { case
> "object": ... }" here?!
>> $parameterstring = "\"" . $params[0] .
>> "\"";
>> eval("OtherClass::" . $method . "(" .
> $parameterstring . ");");
>
> Can't you just say:
>
> OtherClass::$method($params);
>
> here?
>
...
> ---John Holmes...
No, sorry that doesn't work. Interpreter is trying to acces static member
$method .. and this member does not exist.
The error message:
Fatal error: Access to undeclared static property: OtherClass::$method
in ...
Thanks for your time.
vivi