Re: classes in php5
| From: | Matthew Fonda | Date: | Wed, 29 Sep 2004 02:30:06 +0000 |
| Subject: | Re: classes in php5 | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-198142@lists.php.net to get a copy of this message | ||
<?php
class Foo
{ }
$className = "Foo";
$fooInstance = new $className;
?>
Works fine for me. It still works if you add methods or properties to
Foo as well, I'm not sure why it wouldn't work for you, possibly you
have another error along the lines somewhere. I am on PHP 5.0.1 BTW
On Tue, 2004-09-28 at 19:42, Curt Zirzow wrote:
> * Thus wrote Daniel Watrous:
> > 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;
>
> Can you provide the definition of your class Foo. what you describe
> works find in php5.
>
> Curt
> --
> The above comments may offend you. flame at will.