FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How to create an instance from a class name
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: How to create an instance from a class name [message #177819 is a reply to message #177810] Sun, 22 April 2012 14:13 Go to previous messageGo to previous message
Leonardo Azpurua is currently offline  Leonardo Azpurua
Messages: 46
Registered: December 2010
Karma:
Member
"Ross McKay" <au(dot)org(dot)zeta(dot)at(dot)rosko(at)invalid(dot)invalid> escribió en el mensaje
news:nnq6p7p82l6kp0dh4uetmejte0l4umd7so(at)4ax(dot)com...
> On Sat, 21 Apr 2012 20:53:58 -0430, Leonardo Azpurua wrote:
>
>> I am working on a class to generate a report from specs contained in a
>> user
>> defined file.
>> [...]
>> I recall having read somewhere an example of PHP instantiatiting an object
>> from a class name, [...]
>
> $className = 'ExampleClass';
> $instance = new $className;
>
> Can be quite handy in Singletons, e.g.
>
> $className = __CLASS__;
> $instance = new $className;

That's why I couldn't find it.


Thanks!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: session question
Next Topic: Open Source Software Links
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 08:46:32 GMT 2024

Total time taken to generate the page: 0.04695 seconds