<?php error_reporting(E_ALL); class Hoge { var $str = "aaaaaaaa"; function test() { echo $this->str."\n"; } } Hoge::test();
ってやると、
- PHP4
Notice: Undefined variable: this in /************************/test.php on line 9
ってなるけど、
- PHP5
Fatal error: Using $this when not in object context in /************/test.php on line 9
ってなる。ふーん。確かに挙動としてはPHP5の方が正しい。