3v4l.org

run code in 300+ PHP versions simultaneously
<?php /******************************* * author : hishamdalal@gmail.com * version : 3.1 * date : 2013-04-11 *****************************/ class overloadable { protected $fname = null; protected $fargs = array(); //--------------------------------------------------// function set($obj, $fname, $args){ $n = ''; $type = $this->getType($args); $n = "\$o = new $obj();\n"; $n .= "if(method_exists(\$o, '$fname"."_$type')){\n"; $n .= "\t\$r = \$o->$fname"."_$type(". $this->getArgsName($args) .");\n"; $n .= "}else{\n\t\$r = null;\n"; $n .= "\ttrigger_error('function ".$fname."_".$type." is not exist!');\n}"; eval("\$r = $n;"); return $r; } //--------------------------------------------------// function getType($args) { $argType = array(); foreach($args as $i=>$val) { $argType[$i][] = $this->getSuffix($val, $i) ; } $s = ''; if(is_array($argType)){ foreach($argType as $type){ $s .= implode('', $type); } return $s; } return implode('', $argType); } //--------------------------------------------------// function getSuffix($byValarg, $i) { if( is_numeric($byValarg) ) { $type = 'N'; $this->fargs['N'.$i] = $byValarg; } elseif( is_array($byValarg) ) { $type = 'A'; $this->fargs['A'.$i] = $byValarg; } elseif( is_object($byValarg) ) { $type = 'O'; $this->fargs['O'.$i] = $byValarg; } elseif( is_resource($byValarg) ) { $type = 'R'; $this->fargs['R'.$i] = $byValarg; } else { $type = 'S'; $this->fargs['S'.$i] = $byValarg; } return $type; } //--------------------------------------------------// function getArgsName($args){ $r = array(); $ary = array_keys($this->fargs); foreach( $ary as $k=>$v){ $r[]='$this->fargs["'.$v.'"]'; } return implode(", ", $r); } //--------------------------------------------------// function __call($name, $args){ $this->fargs = array(); return $this->set(get_class($this), $name, $args); } //--------------------------------------------------// } class test2 extends overloadable { function foo_(){ echo 'foo - no args'; } function foo_S($s){ echo "foo - one string $s"; } function foo_SS($s1, $s2){ echo "foo - tow strings $s1, $s2"; } function foo_SN($s, $n){ echo "foo - string and number $s, $n"; } function foo_SNN($s, $n){ echo "foo - string and two numbers $s, $n, $n"; } function foo_A($ary){ print_r($ary); } function foo_AA($ary1, $ary2){ if(is_array($ary1) && is_array($ary2)){ echo "foo - tow arrays"; }else{echo 0;} } function foo_O($obj){ echo "foo - "; print_r($obj); } function hi(){ echo "hi - welcome!"; } } echo '<pre>'; $t = new test2(); echo '<br />foo_: '; print_r( $t->foo() ); echo '<br />foo_s: '; print_r( $t->foo('a') ); echo '<br />foo_ss: '; print_r( $t->foo('a', 'b') ); echo '<br />foo_sn: '; print_r( $t->foo('a', 2) ); echo '<br />foo_snn: '; print_r( $t->foo('s', 2, 9) ); echo '<br />foo_a: '; print_r( $t->foo(array(4,5,6,7)) ); echo '<br />foo_aa: '; print_r( $t->foo( array(5,6,7), array(8,9,10) ) ); echo '<br />foo_o: '; print_r( $t->foo($t) ); echo '<br />hi: '; print_r( $t->hi() ); ?>

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)
8.3.60.0070.01418.43
8.3.50.0110.00821.21
8.3.40.0160.00319.04
8.3.30.0070.00719.09
8.3.20.0000.00820.16
8.3.10.0120.00321.83
8.3.00.0030.00620.67
8.2.180.0100.00716.63
8.2.170.0080.01222.96
8.2.160.0140.00019.29
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0040.01526.16
8.2.120.0090.00019.23
8.2.110.0060.00322.12
8.2.100.0040.00719.57
8.2.90.0000.00819.47
8.2.80.0040.00419.38
8.2.70.0030.00617.75
8.2.60.0000.00818.18
8.2.50.0090.00018.07
8.2.40.0090.00018.47
8.2.30.0030.00618.18
8.2.20.0080.00017.82
8.2.10.0080.00017.91
8.2.00.0030.00717.83
8.1.280.0110.00725.92
8.1.270.0110.00422.16
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0030.00623.83
8.1.230.0040.00819.35
8.1.220.0080.00018.04
8.1.210.0050.00318.77
8.1.200.0000.00917.60
8.1.190.0000.00817.52
8.1.180.0000.00918.91
8.1.170.0030.00618.63
8.1.160.0040.00422.22
8.1.150.0040.00418.80
8.1.140.0030.00517.57
8.1.130.0030.00317.88
8.1.120.0000.00717.47
8.1.110.0000.00817.62
8.1.100.0040.00417.52
8.1.90.0000.00817.48
8.1.80.0000.00717.56
8.1.70.0030.00317.54
8.1.60.0030.00617.63
8.1.50.0030.00617.61
8.1.40.0030.00617.50
8.1.30.0030.00517.75
8.1.20.0000.00817.75
8.1.10.0000.00817.69
8.1.00.0030.00617.64
8.0.300.0100.00018.77
8.0.290.0040.00417.18
8.0.280.0030.00518.51
8.0.270.0040.00417.38
8.0.260.0000.00716.94
8.0.250.0000.00717.05
8.0.240.0030.00517.05
8.0.230.0070.00017.08
8.0.220.0030.00317.04
8.0.210.0030.00317.05
8.0.200.0000.00717.03
8.0.190.0000.00817.09
8.0.180.0040.00416.94
8.0.170.0030.00616.93
8.0.160.0040.00416.95
8.0.150.0040.00416.90
8.0.140.0050.00316.79
8.0.130.0000.00613.43
8.0.120.0030.00516.85
8.0.110.0030.00516.92
8.0.100.0070.00016.98
8.0.90.0000.00816.83
8.0.80.0130.00317.05
8.0.70.0080.00016.83
8.0.60.0080.00016.79
8.0.50.0000.00817.04
8.0.30.0120.01217.37
8.0.20.0130.00717.40
8.0.10.0080.00017.07
8.0.00.0140.00516.91
7.4.330.0000.00615.00
7.4.320.0040.00416.68
7.4.300.0070.00016.64
7.4.290.0030.00316.56
7.4.280.0000.00716.61
7.4.270.0050.00316.60
7.4.260.0100.00016.61
7.4.250.0030.00616.68
7.4.240.0050.00216.72
7.4.230.0030.00316.57
7.4.220.0120.00616.75
7.4.210.0060.01016.65
7.4.200.0040.00416.80
7.4.190.0000.00716.71
7.4.160.0130.00316.53
7.4.150.0090.00917.40
7.4.140.0080.01017.86
7.4.130.0100.00816.62
7.4.120.0120.00616.63
7.4.110.0140.00516.54
7.4.100.0100.01016.67
7.4.90.0130.00616.72
7.4.80.0030.01919.39
7.4.70.0060.01116.61
7.4.60.0100.01016.67
7.4.50.0060.00316.63
7.4.40.0070.00722.77
7.4.30.0060.01216.66
7.4.10.0040.01515.21
7.4.00.0100.00815.14
7.3.330.0050.00013.33
7.3.320.0030.00313.53
7.3.310.0040.00416.45
7.3.300.0040.00416.35
7.3.290.0100.00316.54
7.3.280.0060.01016.49
7.3.270.0090.00917.40
7.3.260.0030.01316.38
7.3.250.0050.01616.51
7.3.240.0110.00716.66
7.3.230.0160.00316.46
7.3.210.0070.01016.44
7.3.200.0130.00616.76
7.3.190.0130.00616.69
7.3.180.0130.00416.59
7.3.170.0100.00716.55
7.3.160.0070.01716.44
7.3.130.0030.01014.97
7.3.120.0020.01514.94
7.3.110.0070.01315.27
7.3.100.0110.00414.92
7.3.90.0110.00714.84
7.3.80.0090.00315.12
7.3.70.0090.00914.66
7.3.60.0060.01015.01
7.3.50.0120.00614.97
7.3.40.0000.01515.04
7.3.30.0060.01214.70
7.3.20.0000.01716.73
7.3.10.0030.01216.60
7.3.00.0050.01116.70
7.2.330.0190.00816.75
7.2.320.0150.00316.86
7.2.310.0100.00716.81
7.2.300.0120.00916.50
7.2.290.0170.00616.91
7.2.260.0070.01315.40
7.2.250.0030.01614.79
7.2.240.0070.01115.30
7.2.230.0040.01115.13
7.2.220.0060.01015.14
7.2.210.0070.01015.08
7.2.200.0030.01315.13
7.2.190.0000.01115.12
7.2.180.0040.01115.14
7.2.170.0030.01415.14
7.2.160.0070.00715.03
7.2.150.0070.00717.09
7.2.140.0000.01317.04
7.2.130.0020.01216.74
7.2.120.0050.00916.95
7.2.110.0030.01316.80
7.2.100.0090.00516.94
7.2.90.0070.00916.82
7.2.80.0060.00916.73
7.2.70.0020.01016.91
7.2.60.0040.00916.89
7.2.50.0060.00816.87
7.2.40.0090.00617.02
7.2.30.0030.01116.79
7.2.20.0060.00816.83
7.2.10.0070.00916.75
7.2.00.0070.00917.81
7.1.330.0090.00615.81
7.1.320.0040.01115.53
7.1.310.0000.01316.15
7.1.300.0030.01515.69
7.1.290.0100.00715.85
7.1.280.0070.01015.93
7.1.270.0070.01015.57
7.1.260.0060.00615.78
7.1.250.0040.01115.80
7.1.240.0040.00915.69
7.1.230.0080.00515.88
7.1.220.0030.00915.92
7.1.210.0020.01215.80
7.1.200.0040.01115.65
7.1.190.0060.00715.63
7.1.180.0040.00915.61
7.1.170.0030.01015.69
7.1.160.0070.00915.89
7.1.150.0000.01115.81
7.1.140.0050.00715.74
7.1.130.0050.00915.96
7.1.120.0070.00715.79
7.1.110.0050.00815.78
7.1.100.0040.01116.49
7.1.90.0050.00815.87
7.1.80.0050.00915.79
7.1.70.0050.00516.26
7.1.60.0050.01117.10
7.1.50.0070.01016.18
7.1.40.0090.00615.52
7.1.30.0030.00915.75
7.1.20.0040.00715.90
7.1.10.0060.00615.61
7.1.00.0020.01917.95
7.0.330.0060.00915.42
7.0.320.0040.00915.42
7.0.310.0050.00715.18
7.0.300.0050.00715.41
7.0.290.0020.00915.32
7.0.280.0020.01315.38
7.0.270.0060.00815.46
7.0.260.0020.01015.30
7.0.250.0020.00915.50
7.0.240.0030.01115.46
7.0.230.0070.00415.31
7.0.220.0040.01015.34
7.0.210.0060.00415.38
7.0.200.0050.00615.85
7.0.190.0080.00715.34
7.0.180.0060.00415.46
7.0.170.0020.01015.35
7.0.160.0040.00915.36
7.0.150.0080.00615.55
7.0.140.0040.03217.76
7.0.130.0030.00815.42
7.0.120.0050.00715.49
7.0.110.0030.01115.35
7.0.100.0020.02116.86
7.0.90.0080.02016.92
7.0.80.0060.01616.96
7.0.70.0040.01916.86
7.0.60.0080.02116.92
7.0.50.0050.02117.15
7.0.40.0110.01415.78
7.0.30.0050.01715.68
7.0.20.0070.01715.64
7.0.10.0030.01615.66
7.0.00.0070.01815.74
5.6.400.0070.01114.60
5.6.390.0060.01214.49
5.6.380.0090.00714.61
5.6.370.0020.01214.68
5.6.360.0070.00314.69
5.6.350.0020.01014.65
5.6.340.0030.01314.62
5.6.330.0050.01014.59
5.6.320.0060.00714.78
5.6.310.0040.01214.67
5.6.300.0060.00514.62
5.6.290.0040.00814.75
5.6.280.0070.02716.75
5.6.270.0030.00714.36
5.6.260.0090.00414.50
5.6.250.0060.01816.55
5.6.240.0090.01816.55
5.6.230.0090.01916.44
5.6.220.0020.02516.70
5.6.210.0030.02316.70
5.6.200.0060.01816.75
5.6.190.0030.02616.71
5.6.180.0040.01716.70
5.6.170.0050.01816.65
5.6.160.0050.02016.63
5.6.150.0060.01616.54
5.6.140.0040.02016.63
5.6.130.0080.01716.82
5.6.120.0020.02216.72
5.6.110.0040.01916.64
5.6.100.0050.03416.72
5.6.90.0100.02816.77
5.6.80.0060.03116.36
5.6.70.0100.02916.67
5.6.60.0070.02216.42
5.6.50.0070.03316.59
5.6.40.0080.02216.39
5.6.30.0060.02816.43
5.6.20.0080.02016.47
5.6.10.0010.02716.33
5.6.00.0120.02716.50
5.5.380.0050.02215.44
5.5.370.0040.02115.51
5.5.360.0030.02015.21
5.5.350.0040.01515.29
5.5.340.0050.01815.35
5.5.330.0040.01815.62
5.5.320.0030.02115.49
5.5.310.0060.01615.28
5.5.300.0040.02215.50
5.5.290.0050.01815.52
5.5.280.0030.01815.58
5.5.270.0080.01515.57
5.5.260.0040.01815.63
5.5.250.0060.02515.27
5.5.240.0080.01815.34
5.5.230.0060.03015.17
5.5.220.0050.02115.35
5.5.210.0090.01515.25
5.5.200.0030.02915.36
5.5.190.0100.02915.15
5.5.180.0070.01715.08
5.5.170.0020.01112.70
5.5.160.0070.03215.23
5.5.150.0030.03315.34
5.5.140.0080.01915.23
5.5.130.0100.02815.20
5.5.120.0050.02215.25
5.5.110.0040.03315.31
5.5.100.0060.03215.20
5.5.90.0050.03415.22
5.5.80.0100.02715.33
5.5.70.0070.02915.22
5.5.60.0090.02715.23
5.5.50.0120.02415.25
5.5.40.0070.02215.37
5.5.30.0060.01915.35
5.5.20.0070.02715.29
5.5.10.0050.02115.20
5.5.00.0120.02615.30
5.4.450.0060.01613.99
5.4.440.0030.01514.08
5.4.430.0060.01513.88
5.4.420.0020.02114.13
5.4.410.0060.01514.02
5.4.400.0090.01913.84
5.4.390.0070.02313.84
5.4.380.0060.02013.78
5.4.370.0040.02413.75
5.4.360.0080.02513.91
5.4.350.0040.02913.97
5.4.340.0080.03113.83
5.4.330.0020.01011.36
5.4.320.0070.02713.68
5.4.310.0040.03213.75
5.4.300.0020.02513.79
5.4.290.0030.02113.97
5.4.280.0040.02913.81
5.4.270.0060.02813.79
5.4.260.0040.03013.74
5.4.250.0070.02813.80
5.4.240.0080.02713.77
5.4.230.0070.02813.90
5.4.220.0060.02813.91
5.4.210.0060.02613.78
5.4.200.0040.02913.75
5.4.190.0060.02813.81
5.4.180.0060.02813.86
5.4.170.0050.02713.85
5.4.160.0020.02313.74
5.4.150.0050.02013.90
5.4.140.0040.01513.02
5.4.130.0020.02312.89
5.4.120.0060.02712.99
5.4.110.0070.02712.92
5.4.100.0070.01913.06
5.4.90.0060.02713.02
5.4.80.0040.01913.07
5.4.70.0040.02913.03
5.4.60.0050.03013.00
5.4.50.0050.02913.06
5.4.40.0090.02713.05
5.4.30.0100.02613.01
5.4.20.0030.02313.08
5.4.10.0060.02113.00
5.4.00.0080.02812.78
5.3.290.0070.01912.15
5.3.280.0080.01312.08
5.3.270.0040.02712.14
5.3.260.0030.02912.05
5.3.250.0050.02811.96
5.3.240.0090.01212.06
5.3.230.0060.02712.01
5.3.220.0050.03012.01
5.3.210.0070.02711.97
5.3.200.0010.02111.95
5.3.190.0020.03512.01
5.3.180.0030.02612.05
5.3.170.0060.02612.05
5.3.160.0030.03212.07
5.3.150.0070.02512.04
5.3.140.0060.02112.08
5.3.130.0030.03412.07
5.3.120.0060.02312.08
5.3.110.0020.02712.11
5.3.100.0030.02911.82
5.3.90.0050.02611.89
5.3.80.0040.02711.81
5.3.70.0040.03111.80
5.3.60.0090.02611.82
5.3.50.0020.02911.68
5.3.40.0060.02911.86
5.3.30.0090.01711.74
5.3.20.0050.02911.75
5.3.10.0040.02911.64
5.3.00.0050.02711.62

preferences:
49.53 ms | 401 KiB | 5 Q