I have 2 classes
class A {
// Do some stuff here!
}
and
class B {
public $class = 'A';
public function getClass(){
//Case 1
$class = $this->class;
return new $class(); //work
//Case 2
return new $this->class(); //NOT work
//or to be precise something like this
return new {$this->class}();
}
// Do some other stuff here!
}
Why passing the class property to a var work and accessing directly NOT, like you see in the class above, Case 1 vs. Case 2 ?