Reputation: 446
I am working on a project in CodeIgnitor that is written by someone else While studying the code I came across the following line:
$CI = new $class();
is this $class a PHP built in function to instantiate a generic object? or what is it exactly Thanks in advance
Upvotes: 0
Views: 1332
Reputation: 514
If you have a class, class ExampleClass
, and you have a variable somewhere and you call it $class = "ExampleClass";
you can write the code you specified in the question, which is the same as write $CI = new ExampleClass()
. In php you can do that even with variables.
Upvotes: 1