3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * * Calling static method on a string class or object returned by */ invoking instance method class foo { static function bar(){ static $flag = 1; $flag++; if ($flag == 2 ) { return 'blee'; } if ($flag == 3){ return new blee; } } } class blee { static function baz() { echo "Oh, for the baz of it!\n"; } } /**********************************/ $foo = new foo; echo $foo::bar()::baz(); echo $foo::bar()::baz();
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16, 7.0.0 - 7.0.1
Parse error: syntax error, unexpected 'instance' (T_STRING) in /in/Tdf38 on line 5
Process exited with code 255.

preferences:
166.41 ms | 1395 KiB | 25 Q