I have a class name in variable. I am creating instance and it giving me error. Below is the code example.
use app\controller;
$controller = new controller\$class();
please help.
I have a class name in variable. I am creating instance and it giving me error. Below is the code example.
use app\controller;
$controller = new controller\$class();
please help.
expecting u got a classname like 'Order' soemthing like the following should work:
$class = 'Order';
$order = new $class();
U are using the namespace app/controller, so there is no need to write the namespace "controller/" in front of your variable...
that should work:
$controller = new $class(); //without "controller/"