<?php class aa { public function func() { $this->$bb = 'ああああああ'; $b = 'test2'; return $b; } // 追加 public $c = 1; } $x = new aa(); echo $x->func(); echo $x->$c;
Standard input is empty
test2ああああああ
PHP Notice: Undefined variable: bb in /home/11yQqk/prog.php on line 6 PHP Notice: Undefined variable: c in /home/11yQqk/prog.php on line 17