<[EMAIL PROTECTED]> wrote :

>> Hi,
>> 
>> Tell me if this is the wrong list to ask or if this has been answered
>> somewhere else before. Thanks :)
>> 
>> I am trying to make something like that:
>> 
>> $myClassName = 'MyClass';
>> return $myClassName::myMethod($param1, $param2);
>> 
>> And I get :
>> 
>> Parse error: parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM
>> 
>> I found a way to get around this by using:
>> 
>> return eval(("return $myClassName:: myMethod('$param1', '$param2');");
>> 
>> This works except when one of the parameters is an array.
>> 
>> What is this ?
>> Is it a bug or a feature and will it change in ZE2 ?
>> Is there another way to get around this to let it accept arrays ?
>> 
> 
> Its neither, its a fact of the language, the following:
> 
> $classname::method is illegal, you recieved a parse error to that
> effect.  the best thing to do is::

I don't understand why it is illegal...

> call_user_func(array($className, 'method'), $param1, $param2);

This won't work because, in my case, I don't want to make an instance of
$className but rather use $className methods as if they were plugged inside
my main object.

To explain my problem:

I have a container object which is standardized and has a few get/set
methods as well as addChild, getParent and so on. This can be considered
like my MODEL.

My MODEL is created using different datasources in different formats. For
each of these formats, I have created a parser. I want to be able to call
this parser method from inside my MODEL and have it dynamically constructed
that way.

And because the parsing is often recursive, I need to be able to have a
reference to $this all the time, from the parsing method.

This is the reason why I used :: which allows to dynamically extend the
functionalities of my MODEL object while allowing it to access $this. This
was working very well (with eval), up to the point where I needed arrays
passed as parameters.

Now I wonder if there are some other ways or if the behaviour of :: for this
kind of plugin behaviour can be changed.

Thanks,

Bertrand Mansion
Mamasam



--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to