3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { const BAR = 'bar'; var $other = 'test'; } function getFoo() { return new Foo(); } // var_dump(getFoo()::BAR); // Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) var_dump((getFoo())->BAR); // NULL (Notice: Undefined property Foo::$BAR) var_dump(getFoo()->other); // string(4) "test" $foo = getFoo(); var_dump($foo::BAR);

preferences:
37.46 ms | 402 KiB | 5 Q