use a variabel as a class name in php or cakephp 3

You need to separate your classname and use variables variable

foreach ($classes as $class) {
    $_class = "\\App\\Command\\{$class}Command";
    $class_name = $class . 'Command';
    $$class_name = new $_class;
    # code...
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top