3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tpnb = 5; test(); die(); function test() { global $tpnb; error_log('$tpnb value: ' . $tpnb . ' type:' . gettype($tpnb)); $xmlStruct = <<<EOF <?xml version="1.0" encoding="UTF-8"?> <templates> <object type="obj_1" label="Label for object 1"></object> <object type="obj_2" label="Label for object 2"></object> <object type="obj_3" label="Label for object 3"></object> <object type="obj_4" label="Label for object 4"></object> <object type="obj_5" label="Label for object 5"></object> <object type="obj_6" label="Label for object 6"></object> <object type="obj_7" label="Label for object 7"></object> <object type="obj_8" label="Label for object 8"></object> <object type="obj_9" label="Label for object 9"></object> <object type="obj_10" label="Label for object 10"></object> </templates> EOF; $tplxml = simplexml_load_string($xmlStruct); echo '<table border="1">'; echo '<tr>'; echo'<td style="vertical-align:top"><pre><h1>1: $tpnb</h1>'; // try accessing "object" directly print_r($tplxml->object[$tpnb]); echo '</pre></td>'; echo'<td style="vertical-align:top"><pre><h1>2: (int) $tpnb</h1>'; // try accessing "object" with an index cast print_r($tplxml->object[(int) $tpnb]); echo '</pre></td>'; echo'<td style="vertical-align:top"><pre><h1>3: ($tpnb + 1 - 1)</h1>'; // try accessing "object" by increasing and decreasing the index print_r($tplxml->object[($tpnb + 1 - 1)]); echo '</pre></td>'; echo'<td style="vertical-align:top"><pre><h1>4: temp var</h1>'; // use a temporary variable to re-set the index in the same variable $tpnbx = $tpnb; unset($tpnb); $tpnb = $tpnbx; print_r($tplxml->object[$tpnb]); echo '</pre></td>'; echo '</tr></table>'; }

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.0140.00018.93
8.3.50.0210.00018.38
8.3.40.0070.00719.22
8.3.30.0120.00319.04
8.3.20.0040.00420.46
8.3.10.0040.00423.73
8.3.00.0060.00319.75
8.2.180.0110.00716.88
8.2.170.0110.00322.96
8.2.160.0140.00319.54
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0000.00722.38
8.2.120.0050.00226.35
8.2.110.0000.01021.16
8.2.100.0080.00318.09
8.2.90.0000.00819.42
8.2.80.0090.00017.97
8.2.70.0000.00817.88
8.2.60.0090.00018.05
8.2.50.0090.00018.10
8.2.40.0000.00822.50
8.2.30.0050.00319.47
8.2.20.0040.00418.04
8.2.10.0050.00318.30
8.2.00.0070.00018.41
8.1.280.0150.00325.92
8.1.270.0050.00323.96
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0050.00524.10
8.1.230.0040.01119.08
8.1.220.0050.00317.89
8.1.210.0040.00418.77
8.1.200.0100.00317.60
8.1.190.0000.00817.50
8.1.180.0080.00018.10
8.1.170.0040.00418.71
8.1.160.0000.00722.37
8.1.150.0040.00420.91
8.1.140.0030.00619.86
8.1.130.0000.00717.92
8.1.120.0040.00417.58
8.1.110.0080.00017.63
8.1.100.0000.00717.61
8.1.90.0040.00417.75
8.1.80.0040.00417.61
8.1.70.0030.00317.57
8.1.60.0040.00417.87
8.1.50.0040.00417.79
8.1.40.0030.00617.63
8.1.30.0030.00517.79
8.1.20.0000.00817.95
8.1.10.0030.00617.86
8.1.00.0030.00617.77
8.0.300.0040.00418.77
8.0.290.0000.00716.88
8.0.280.0000.00718.68
8.0.270.0000.00717.02
8.0.260.0000.00717.59
8.0.250.0030.00317.30
8.0.240.0050.00317.22
8.0.230.0000.00817.11
8.0.220.0000.00717.05
8.0.210.0050.00317.09
8.0.200.0030.00617.11
8.0.190.0040.00417.27
8.0.180.0040.00417.10
8.0.170.0040.00417.07
8.0.160.0050.00217.07
8.0.150.0070.00017.20
8.0.140.0050.00317.20
8.0.130.0060.00013.68
8.0.120.0040.00417.04
8.0.110.0040.00417.13
8.0.100.0000.00717.29
8.0.90.0060.00317.11
8.0.80.0130.00317.16
8.0.70.0080.00016.98
8.0.60.0000.00717.11
8.0.50.0040.00417.10
8.0.30.0090.00917.34
8.0.20.0110.00817.40
8.0.10.0000.00717.15
8.0.00.0150.00717.11
7.4.330.0030.00315.49
7.4.320.0030.00316.77
7.4.300.0040.00416.79
7.4.290.0030.00316.72
7.4.280.0030.00616.74
7.4.270.0030.00316.75
7.4.260.0030.00416.71
7.4.250.0070.00016.57
7.4.240.0040.00416.83
7.4.230.0030.00316.92
7.4.220.0100.00716.74
7.4.210.0130.01016.86
7.4.200.0000.00716.56
7.4.160.0080.00816.76
7.4.150.0140.00517.40
7.4.140.0050.01317.86
7.4.130.0070.01116.84
7.4.120.0130.00616.80
7.4.110.0130.01316.80
7.4.100.0030.01316.91
7.4.90.0150.00416.84
7.4.80.0070.01419.39
7.4.70.0130.00416.71
7.4.60.0070.01116.75
7.4.50.0050.00516.59
7.4.40.0070.01016.87
7.4.30.0150.00616.88
7.4.00.0060.00915.19
7.3.330.0000.00613.64
7.3.320.0000.00513.67
7.3.310.0030.00516.69
7.3.300.0050.00216.69
7.3.290.0060.01216.68
7.3.280.0100.00816.66
7.3.270.0120.00617.40
7.3.260.0100.00816.61
7.3.250.0120.00616.74
7.3.240.0080.01316.63
7.3.230.0110.00616.56
7.3.210.0030.01616.71
7.3.200.0070.01017.00
7.3.190.0040.01916.85
7.3.180.0100.00716.63
7.3.170.0150.00316.77
7.3.160.0090.00916.71
7.2.330.0130.00317.18
7.2.320.0090.00917.01
7.2.310.0130.00316.72
7.2.300.0130.00617.02
7.2.290.0060.01116.82
7.2.110.1290.01316.52
7.2.60.0040.01117.03
7.2.00.0100.00719.48
7.1.200.0070.00415.84
7.1.100.0060.00617.95
7.1.70.0000.00816.99
7.1.60.0060.01019.38
7.1.50.0070.01617.05
7.1.00.0070.07722.44
7.0.200.0320.00414.81
7.0.90.0230.07020.20
7.0.80.0200.06320.05
7.0.70.0130.05320.17
7.0.60.0100.04319.96
7.0.50.0000.06020.32
7.0.40.0030.04320.15
7.0.30.0130.03320.20
7.0.20.0030.04320.28
7.0.10.0000.09720.07
7.0.00.0170.06020.20
5.6.230.0030.05320.87
5.6.220.0030.06020.54
5.6.210.0070.04320.67
5.6.200.0100.04321.10
5.6.190.0070.04021.29
5.6.180.0070.03321.15
5.6.170.0030.05021.09
5.6.160.0070.04321.10
5.6.150.0070.03721.11
5.6.140.0130.02721.13
5.6.130.0100.05721.13
5.6.120.0070.04021.19
5.6.110.0030.04321.09
5.6.100.0070.04021.12
5.6.90.0070.04021.05
5.6.80.0070.03720.68
5.6.70.0030.04020.66
5.6.60.0130.03020.48
5.6.50.0030.03320.49
5.6.40.0000.04320.50
5.6.30.0070.05720.44
5.6.20.0100.03320.48
5.6.10.0030.04320.34
5.6.00.0030.03320.50

preferences:
59.45 ms | 401 KiB | 5 Q