Pergunta de entrevista da empresa CarltonOne Engagement

class Test{ protected $var; public function __construct(){ $this->var=1; } public static someFunction(){ return $this->var *= 5; } } What is wrong with the code ?

Resposta da entrevista

Sigiloso

5 de nov. de 2018

static function cannot use $this. We can use Class Name or self with scope resolution operation to reference a static variable. Test::$var or self::$var and also such referencing needs variable to be declared as static.