3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Foo { public function test() { // This should fatal but does not.. Bar::test(); } public function do_something_totally_insane() { echo "OH NOES!\n"; } } class BaseBar { public function do_something_totally_insane() { echo "OK\n"; } } final class Bar extends BaseBar { private $int_x = 0; public function test() { $this->do_something_totally_insane(); $this->int_x = 2323532; } } echo "TEST 1\n"; $obj_bar = new Bar; $obj_bar->test(); print_r($obj_bar); echo "TEST 2\n"; $obj_foo = new Foo; $obj_foo->test(); print_r($obj_foo); echo "TEST 3\n"; Bar::test();
Output for git.master, git.master_jit, rfc.property-hooks
TEST 1 OK Bar Object ( [int_x:Bar:private] => 2323532 ) TEST 2 Fatal error: Uncaught Error: Non-static method Bar::test() cannot be called statically in /in/sbWEo:9 Stack trace: #0 /in/sbWEo(40): Foo->test() #1 {main} thrown in /in/sbWEo on line 9
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
39.97 ms | 401 KiB | 8 Q