smth like Class.forName() in PHP?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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?

Sergei Riaguzov wrote:
Quoted text here. Click to load it


$var=new $className();

Site Timeline