Do you mean instantiate an existing class, or actually run code to create a new class that does not yet even exist?
$obj = new "myclass" is a meaningless piece of code. The "new" keyword means to create a new object of an existing class, not to create a new class. Thus the quotes make no sense, because you are still just using a word, with no variable interpolation. $obj = new myclass;, on the other hand, is a perfectly normal piece of code, assuming there is a class already existing called "myclass", but I guess it doesn't accomplish what you want.
If you want to actually run code that defines a new class, you would probably want to build a string that consists of the code you want to run, and then run it with the eval($your_string) function. (see
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.