3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $a = ['a', 'b', 'c']; public function count() { return count($this->a); } public function get($i) { return $this->a[$i]; } } $foo = new Foo; echo 'Missing "a" (last record) and fails first record as count() is 1 position higher than total indexes' . \PHP_EOL; for($i = $foo->count(); $i > 0; $i--){ echo $foo->get($i) . \PHP_EOL; } echo \PHP_EOL . '---' . \PHP_EOL . \PHP_EOL; for($i = $foo->count()-1; $i >= 0; $i--){ echo $foo->get($i) . \PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
Missing "a" (last record) and fails first record as count() is 1 position higher than total indexes Warning: Undefined array key 3 in /in/tQPPB on line 14 c b --- c b a

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