you are just missing the (); it wont work either in php4 or php5 that
way.

 $className = "Foo";
 $fooInstance = new $className();

Cheers

On Tue, Sep 28, 2004 at 01:46:27PM -0600, Daniel Watrous wrote:
> Hello all,
> 
> I have a class Foo.  In PHP4 I could create an instance of Foo in the following 
> manner:
> $className = "Foo";
> $fooInstance = new $className;
> 
> This would yield the same result as:
> $fooInstance = new Foo;
> 
> In my efforts to port this over to PHP5 I am having trouble.  Not only do I not get 
> back an instance of my Foo class, but the script execution stops entirely without so 
> much as a warning.  Is this a bug?  Is there a new mechanism in PHP5, such as a 
> getInstance function (i.e. object getInstance (string className))?  Thanks in 
> advance for any comments!
> 
> Daniel
-- 

Maciek Ruckgaber Bielecki



"The wireless telegraph is not difficult to understand. The ordinary telegraph is like 
a very long cat. You pull the tail in New York, and it meows in Los Angeles. The 
wireless is the same, only without the cat. " 
--Albert Einstein--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to