Tuesday 15 April 2014

php - How to use defined data as function or class name? -


I have defined a data as below.

  Define ('INDEX_CONTROLLER', 'test');   

and I want to use it as below.

  need_once 'Controller /' INDEX_CONTROLLER '.php'; $ This- & gt; Admin = new INDEX_CONTROLLER ();   

I'm getting the error below.

Fatal error: Class 'INDEX_CONTROLLER' /var/www/own/boot.php not found in you You can set it to a variable and then call it:

< Previous> $ controller = INDEX_CONTROLLER; $ This- & gt; Controller = new $ controller ();

No comments:

Post a Comment