3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Record { protected $index=0; //page index protected $pages=[]; //pages array public function nextPage() { $this->index++; } public function addRecord($key, $value) { $this->pages[$this->index][$key] = $value; } public function getPage($index) { if ($index > $this->index) return NULL; else return $this->pages[$this->index]; } } class AdditiveRecord extends Record { private function getSums($range) { $sums = $this->pages[$range[0]]; $lim = ($range[1] <= $this->index) ? $range[1] : $this->index; for ($i = $range[0]+1;$i<$lim;$i++) { foreach($this->pages[$i] as $k=>$v) $sums[$k] += $v; } return $sums; } } $m = new AdditiveRecord(); for ($j = 1;$j<3;$j++) { for ($i = 1;$i<10;$i++) $m.addElement($i,$j*10+$i); $m->nextPage(); } $m->getSums([0,1]);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function addElement() in /in/MraKW:36 Stack trace: #0 {main} thrown in /in/MraKW on line 36
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:
53.91 ms | 401 KiB | 8 Q