3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function do_something() { echo "class A did something"; } } class B { private $arr = array(); private $current_index = 0; public function add_new_A() { $new_a = new A; $this->arr[$this->current_index] = $new_a; $this->current_index++; } public function get_an_A_by_index($index) { return $this->arr[$index]; } public function do_something_with_A_member_inside_array($index) { self::get_an_A_by_index($index)->do_something(); } } $b = new B; $b->add_new_a(); $b->add_new_a(); echo print_r($b->get_an_A_by_index(0)); echo "\n"; $b->do_something_with_A_member_inside_array(0); // returns error
Output for git.master, git.master_jit, rfc.property-hooks
A Object ( ) 1 class A did something

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:
27.39 ms | 405 KiB | 5 Q