You are here: Re: [PHP] Re: dynamic object instances « PHP « IT news, forums, messages
Re: [PHP] Re: dynamic object instances

Posted by Jochem Maas on 08/11/05 11:06

Eli wrote:
> Jochem Maas wrote:
>
>> Eli wrote:
>>
>>> <?
>>> $obj_eval="return new $class(";
>>> for ($i=0; $i<count($args); $i++)
>>> $obj_eval.="\$args[$i],";
>>> $obj_eval=substr($obj_eval,0,-1).");";
>>> $obj=eval($obj_eval);
>>> ?>
>>
>>
>>
>> I believe that this is the kind of clever, evil stuff the OP was
>> trying to avoid...
>> (evil - eval :-) - besides eval is very slow - not something you (well
>> me then) want to
>> use in a function dedicated to object creation which is comparatively
>> slow anyway
>> (try comparing the speed of cloning and creating objects in php5 for
>> instance
>>
>> regardless - nice one for posting this Eli - I recommend anyone who
>> doesn't understand
>> what he wrote to go and figure it out, good learning material :-)
>>
>>>
> You're right that using eval() slows.. But using the _init() function as
> you suggested is actually tricking in a way you move the constructor
> params to another function, but the initialization params should be sent
> to the constructor!

true enough, thats why I suggested the OP might want to reevaluate the whole
idea ... personally I don't see much point in a create() function for new objects.

but anyway :-)

>
> I guess that it would be better if PHP will add a possibility to
> construct a dynamic class with variant number of params... ;-)

there is always runkit.

>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация