3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CParent { private $arrMember = array(); private $mark; function __construct() { $this->setAttr(); } protected abstract function init(); 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.0200.04112.38
5.4.150.0180.04812.37
5.4.140.0250.06512.05
5.4.130.0180.04412.04
5.4.120.0150.04312.00
5.4.110.0200.05611.99
5.4.100.0140.04411.99
5.4.90.0130.04612.00
5.4.80.0180.04111.99
5.4.70.0220.04911.99
5.4.60.0150.04211.99
5.4.50.0290.07711.99
5.4.40.0180.04111.98
5.4.30.0250.06411.97
5.4.20.0140.04411.98
5.4.10.0160.03911.98
5.4.00.0190.05311.47
5.3.260.0160.04412.72
5.3.250.0160.04412.72
5.3.240.0190.04512.72
5.3.230.0180.04312.71
5.3.220.0170.04612.68
5.3.210.0200.05512.68
5.3.200.0160.04512.68
5.3.190.0150.04612.67
5.3.180.0150.04612.67
5.3.170.0200.05812.67
5.3.160.0190.04212.67
5.3.150.0240.06912.67
5.3.140.0140.04912.66
5.3.130.0190.04212.66
5.3.120.0200.05612.65
5.3.110.0210.04312.66
5.3.100.0230.06912.12
5.3.90.0150.04512.09
5.3.80.0170.04612.09
5.3.70.0180.04312.08
5.3.60.0220.04312.07
5.3.50.0260.06712.01
5.3.40.0190.04312.01
5.3.30.0150.04511.97
5.3.20.0240.06711.76
5.3.10.0130.04711.73
5.3.00.0250.06711.70

preferences:
138.8 ms | 1386 KiB | 7 Q