smth like Class.forName() in PHP?

smth like Class.forName() in PHP?

am 12.04.2008 17:54:50 von Sergei Riaguzov

Is there a way to create an instance of a class SomeClass in PHP having
a string "SomeClass"? The idea is to create instances on classes based
on dynamic information obtained from $_POST. Like

Java has a useful construct for that - Class.forName(). Is it possible
to do same in PHP? Like:

$obj = createClass($_POST['className'])

or smth?

Re: smth like Class.forName() in PHP?

am 12.04.2008 18:10:35 von Alexey Kulentsov

Sergei Riaguzov wrote:
> Is there a way to create an instance of a class SomeClass in PHP having
> a string "SomeClass"?

$className='SomeClass';

$var=new $className();