{"id":176,"date":"2011-05-15T10:39:09","date_gmt":"2011-05-15T20:39:09","guid":{"rendered":"http:\/\/mymonkeydo.com\/?p=176"},"modified":"2011-05-15T10:39:09","modified_gmt":"2011-05-15T20:39:09","slug":"creating-an-instance-of-a-php-class","status":"publish","type":"post","link":"https:\/\/mymonkeydo.com\/creating-an-instance-of-a-php-class\/","title":{"rendered":"Creating an Instance of a PHP Class"},"content":{"rendered":"
This works in PHP 5.3+:<\/p>\n
$CLASS_NAME = 'TheName';\n\n$class_instance = new $CLASS_NAME;<\/pre>\nThis doesn’t<\/p>\n
define('CLASS_NAME', 'TheName');\n\n$class_instance = new CLASS_NAME;<\/pre>\n<\/p>\n
Workaround:<\/h2>\n