3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Record { private $index=0; //page index private $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]; } } $r = new Record(); $r->addRecord("t","m"); var_dump($r->getPage(0));
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined variable $pages in /in/MQMgP on line 12 Deprecated: Creation of dynamic property Record::$ is deprecated in /in/MQMgP on line 12 Warning: Undefined array key 0 in /in/MQMgP on line 18 NULL
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Warning: Undefined variable $pages in /in/MQMgP on line 12 Warning: Undefined array key 0 in /in/MQMgP on line 18 NULL
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: pages in /in/MQMgP on line 12 Notice: Undefined offset: 0 in /in/MQMgP on line 18 NULL
Output for 7.3.32 - 7.3.33
NULL
Output for 7.0.0 - 7.0.33
Notice: Undefined variable: pages in /in/MQMgP on line 12 Fatal error: Uncaught Error: Cannot access empty property in /in/MQMgP:12 Stack trace: #0 /in/MQMgP(23): Record->addRecord('t', 'm') #1 {main} Next Error: Cannot access empty property in /in/MQMgP:12 Stack trace: #0 /in/MQMgP(23): Record->addRecord('t', 'm') #1 {main} thrown in /in/MQMgP on line 12
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Notice: Undefined variable: pages in /in/MQMgP on line 12 Fatal error: Cannot access empty property in /in/MQMgP on line 12
Process exited with code 255.

preferences:
319.41 ms | 402 KiB | 376 Q