Is it possible to initialize a variable in the constructor without creating an instance of the class? For example :
class Class { private $value public function __construct ($val){ $this->value = $val } /** * @Route("/", methods="POST") */ public function get(){ echo $this->value; } }
$this, so your "for example" is not at all clear. - teran$valuevariable is initialized in it. I wanted to make sure that knowledgeable people do not in this part of the code whether it happens “somehow”. I will look further - HegoJuneполучил на руки странный код (работающий) в котором ситуация выглядит именно так.try this:$c = new Class1(1); $c->__construct(2); var_dump($c->get());$c = new Class1(1); $c->__construct(2); var_dump($c->get());. In addition, there may be traits, inheritance. After all, you are watching the wrong file. Use the Reflection API to examine the object. Well __wakeup - Total Pusher