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()->other); // string(4) "test" var_dump(getFoo()::BAR); // Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) var_dump((getFoo())::BAR); // Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) $foo = getFoo(); var_dump($foo->other); // string(4) "test" var_dump($foo::BAR); // string(3) "bar"

preferences:
40.78 ms | 402 KiB | 5 Q