Re: PHP5: __call() implementation EXAMPLE
| From: | Vivian Steller | Date: | Thu, 05 Feb 2004 15:51:22 +0000 |
| Subject: | Re: PHP5: __call() implementation EXAMPLE | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176900@lists.php.net to get a copy of this message | ||
Vivian Steller wrote:
...
> 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
> $parameterstring = "\"" . $params[0] . "\"";
> eval("OtherClass::" . $method .
> "(" . $parameterstring . ");");
>
> }
> }
...
ok, i'm sorry, but i found the solution for my own:
on the top you see some snippet of my EXAMPLE Message before.
you can implement the $parameterstring generation algorithm like this (and
its very very easy!!)
$parameterstring = "";
for($i = 0; $i < count($params); $i++) {
if(!empty($parameterstring)) {
$parameterstring .= ", ";
}
$parameterstring .= "\$params[" . $i . "]";
}
replace the line "$parameterstring = "\"" . $params[0] .
"\"";" with this
code snippet and it works...
any way, thanks.
vivi