3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Call a static method on a string class or object returned by // an instance method call $foo->bar()::baz(); class bla { 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 bla; echo $foo::bar()::baz();
based on Qug8P
Output for 7.0.5 - 7.2.0
Notice: Undefined variable: foo in /in/EcGZn on line 4 Fatal error: Uncaught Error: Call to a member function bar() on null in /in/EcGZn:4 Stack trace: #0 {main} thrown in /in/EcGZn on line 4
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: foo in /in/EcGZn on line 4 Fatal error: Uncaught Error: Call to a member function bar() on unknown in /in/EcGZn:4 Stack trace: #0 {main} thrown in /in/EcGZn on line 4
Process exited with code 255.
Output for 5.4.11 - 5.6.21
Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) in /in/EcGZn on line 4
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /in/EcGZn on line 4
Process exited with code 255.