3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CParent { private $arrMember = array(); private $mark; function __construct{ /* * If parent constructor run first, init() method'll get blank array. */ $this->setAttr(); } protected function init(){ return array(); } private function setAttr(){ $arr = $this->init(); foreach ($arr as $item){ array_push($this->arrMember, $item['name']); if (isset($item['mark']) && $item['mark'] == TRUE) $this->mark = $item['name']; } } } class CChild extends CParent { /* * I'd like to define variable within this method then pass to parent class. */ protected function init(){ return array( array('name' => 'v1', 'mark' => true), array('name' => 'v2'), array('name' => 'v3') ); } } print_r( new CChild);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.160.0090.04312.39
5.4.150.0090.04312.39
5.4.140.0110.04212.08
5.4.130.0110.04112.06
5.4.120.0110.04212.02
5.4.110.0090.04312.02
5.4.100.0100.04112.02
5.4.90.0180.06012.02
5.4.80.0100.05112.02
5.4.70.0120.04012.02
5.4.60.0070.04512.02
5.4.50.0090.04512.02
5.4.40.0150.05112.00
5.4.30.0100.04412.00
5.4.20.0070.04112.00
5.4.10.0100.03912.00
5.4.00.0080.04211.50
5.3.260.0120.04112.72
5.3.250.0070.04412.72
5.3.240.0130.03912.72
5.3.230.0120.04012.71
5.3.220.0120.03912.68
5.3.210.0090.04212.68
5.3.200.0150.03712.68
5.3.190.0130.04112.68
5.3.180.0110.04312.67
5.3.170.0140.04012.67
5.3.160.0130.03912.67
5.3.150.0100.04012.67
5.3.140.0100.04212.66
5.3.130.0130.04412.65
5.3.120.0110.04712.66
5.3.110.0130.04012.66
5.3.100.0120.04112.12
5.3.90.0090.04312.10
5.3.80.0140.03812.09
5.3.70.0110.04512.09
5.3.60.0130.04212.07
5.3.50.0130.05212.02
5.3.40.0110.04712.02
5.3.30.0120.04611.98
5.3.20.0100.04311.77
5.3.10.0150.04911.73
5.3.00.0110.04311.71

preferences:
143.1 ms | 1398 KiB | 8 Q