smth like Class.forName() in PHP?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sergei Riaguzov

    smth like Class.forName() in PHP?

    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($_P OST['className'])

    or smth?
  • Alexey Kulentsov

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

    Sergei Riaguzov wrote:
    Is there a way to create an instance of a class SomeClass in PHP having
    a string "SomeClass" ?
    $className='Som eClass';

    $var=new $className();

    Comment

    Working...