Can PHP instantiate an object from the name of the class as a string?

class, initialization, object, php

Solution

Yep, definitely.

$className = 'MyClass';
$object = new $className; 

Problem

Is it possible in PHP to instantiate an object from the name of a class, if the class name is stored in a string?

Original source