3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Example: SimpleXML tell apart a single element and a list of elements with a single element * * @link https://hakre.wordpress.com/2013/02/12/simplexml-type-cheatsheet/ * @libk http://stackoverflow.com/a/14829309/367456 */ $buffer = <<<XML <root> <result>the one childre</result> </root> XML; $xml = simplexml_load_string($buffer); /** * @param SimpleXMLElement $element */ function sxml_show_info(SimpleXMLElement $element) { $isSingleElement = $element[0] == $element; $isListOfElements = $element[0] != $element and $element->attributes() !== NULL; printf(" Is single-element? - %s\n", $isSingleElement ? 'Yes' : 'No'); printf(" Is list-of-elements? - %s\n", $isListOfElements ? 'Yes' : 'No'); } echo "For the single element:\n"; sxml_show_info($xml->result[0]); echo "\n"; echo "For the list of elements with a single item:\n"; sxml_show_info($xml->result); echo "\n";

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.0150.00618.43
8.3.50.0110.00822.08
8.3.40.0070.00719.17
8.3.30.0090.00619.30
8.3.20.0070.00020.42
8.3.10.0050.00322.02
8.3.00.0040.00422.32
8.2.180.0090.00918.48
8.2.170.0090.00619.07
8.2.160.0110.00722.96
8.2.150.0050.00225.66
8.2.140.0060.00324.66
8.2.130.0000.00826.16
8.2.120.0030.00618.00
8.2.110.0060.00320.43
8.2.100.0080.00318.09
8.2.90.0000.00819.52
8.2.80.0000.00817.97
8.2.70.0100.00017.75
8.2.60.0040.00418.05
8.2.50.0000.00818.07
8.2.40.0030.00621.38
8.2.30.0000.00718.18
8.2.20.0000.00918.02
8.2.10.0040.00418.26
8.2.00.0040.00418.34
8.1.280.0130.00725.92
8.1.270.0070.00320.38
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0030.00724.11
8.1.230.0040.00722.23
8.1.220.0040.00418.01
8.1.210.0030.00518.77
8.1.200.0070.00317.50
8.1.190.0080.00017.48
8.1.180.0050.00318.10
8.1.170.0040.00418.51
8.1.160.0020.00522.18
8.1.150.0040.00419.11
8.1.140.0050.00319.74
8.1.130.0000.00817.93
8.1.120.0040.00417.70
8.1.110.0070.00017.64
8.1.100.0030.00717.59
8.1.90.0000.00717.54
8.1.80.0040.00417.69
8.1.70.0000.00717.59
8.1.60.0040.00417.78
8.1.50.0050.00317.60
8.1.40.0060.00317.61
8.1.30.0090.00017.69
8.1.20.0040.00417.84
8.1.10.0040.00417.79
8.1.00.0000.00817.61
8.0.300.0000.00718.77
8.0.290.0000.00716.88
8.0.280.0070.00018.55
8.0.270.0030.00317.44
8.0.260.0030.00317.29
8.0.250.0060.00017.24
8.0.240.0000.00817.11
8.0.230.0000.00717.14
8.0.220.0040.00417.09
8.0.210.0070.00017.12
8.0.200.0030.00317.28
8.0.190.0040.00417.22
8.0.180.0030.00617.16
8.0.170.0070.00017.14
8.0.160.0040.00417.06
8.0.150.0040.00417.21
8.0.140.0040.00417.21
8.0.130.0000.00613.57
8.0.120.0000.00817.09
8.0.110.0030.00617.05
8.0.100.0000.00717.15
8.0.90.0000.00717.21
8.0.80.0190.00317.22
8.0.70.0080.00016.95
8.0.60.0070.00017.03
8.0.50.0040.00417.05
8.0.30.0110.00817.32
8.0.20.0190.01817.51
8.0.10.0000.00717.10
8.0.00.0070.01016.96
7.4.330.0000.00615.35
7.4.320.0000.00616.82
7.4.300.0000.00616.57
7.4.290.0000.00716.69
7.4.280.0040.00416.61
7.4.270.0030.00516.70
7.4.260.0040.00416.59
7.4.250.0000.00716.71
7.4.240.0030.00516.69
7.4.230.0070.00016.72
7.4.220.0130.00616.64
7.4.210.0070.00716.63
7.4.200.0050.00316.83
7.4.160.0060.01016.61
7.4.150.0290.01317.40
7.4.140.0110.01017.86
7.4.130.0110.01016.76
7.4.120.0070.01216.72
7.4.110.0120.00916.75
7.4.100.0000.02316.75
7.4.90.0110.00816.65
7.4.80.0070.01119.39
7.4.70.0140.00316.56
7.4.60.0060.00916.76
7.4.50.0030.00616.61
7.4.40.0120.00816.85
7.4.30.0070.01716.93
7.4.00.0110.00715.14
7.3.330.0030.00413.46
7.3.320.0060.00013.64
7.3.310.0030.00316.67
7.3.300.0000.00716.55
7.3.290.0080.00816.61
7.3.280.0080.01016.64
7.3.270.0140.01017.40
7.3.260.0090.00916.59
7.3.250.0110.00616.65
7.3.240.0120.00416.62
7.3.230.0100.01016.76
7.3.210.0030.01316.73
7.3.200.0050.01419.39
7.3.190.0060.01516.59
7.3.180.0160.00016.56
7.3.170.0070.01016.61
7.3.160.0060.01316.63
7.3.10.0090.00516.79
7.3.00.0050.00816.47
7.2.330.0090.00916.69
7.2.320.0150.00917.00
7.2.310.0100.01316.70
7.2.300.0090.00916.60
7.2.290.0030.01616.98
7.2.130.0040.01116.90
7.2.120.0090.00816.80
7.2.110.0060.00917.04
7.2.100.0050.00916.87
7.2.90.0090.00717.04
7.2.80.0060.00616.99
7.2.70.0100.00617.00
7.2.60.0050.01216.82
7.2.50.0020.01316.91
7.2.40.0050.00816.98
7.2.30.0050.01116.99
7.2.20.0050.01016.98
7.2.10.0030.00916.96
7.2.00.0060.00617.79
7.1.250.0070.00715.87
7.1.200.0000.00716.00
7.1.100.0030.01218.09
7.1.70.0000.00817.31
7.1.60.0100.01419.59
7.1.50.0070.01417.19
7.1.00.0000.08022.50
7.0.200.0120.00614.82
7.0.60.0130.07320.14
7.0.50.0100.03318.02
7.0.40.0100.04320.04
7.0.30.0370.08020.33
7.0.20.0230.05720.17
7.0.10.0170.04720.28
7.0.00.0000.08720.21
5.6.280.0030.06721.14
5.6.210.0130.05020.91
5.6.200.0130.08018.20
5.6.190.0100.07720.57
5.6.180.4070.05020.80
5.6.170.0300.07320.66
5.6.160.0070.08320.63
5.6.150.0070.07318.38
5.6.140.0000.05318.24
5.6.130.0100.07718.34
5.6.120.0100.03721.04
5.6.110.0130.08021.17
5.6.100.0000.05321.04
5.6.90.0000.05020.99
5.6.80.0070.08320.42
5.6.70.0230.07320.43
5.5.350.0370.07320.43
5.5.340.0070.05718.10
5.5.330.0000.09320.60
5.5.320.0330.08020.42
5.5.310.0200.04320.38
5.5.300.0130.07018.13
5.5.290.0130.06018.12
5.5.280.0030.05720.93
5.5.270.0030.05021.00
5.5.260.0100.06720.80
5.5.250.0130.08020.59
5.5.240.3700.04320.13
5.4.450.0470.06719.54
5.4.440.0770.06319.62
5.4.430.0670.05319.30
5.4.420.0870.04019.45
5.4.410.0800.05319.50
5.4.400.0630.06019.32
5.4.390.0700.05719.39
5.4.380.0630.06319.17
5.4.370.0600.06319.29
5.4.360.0700.05319.31
5.4.350.0670.06019.31
5.4.340.0700.05319.19
5.4.320.0870.06019.25
5.4.310.0670.06018.96
5.4.300.0730.06319.21
5.4.290.0930.05019.36
5.4.280.0600.05319.27
5.4.270.0800.06019.29
5.4.260.0830.06019.11
5.4.250.0600.05719.24
5.4.240.0730.06019.25
5.4.230.0830.05719.16
5.4.220.0830.04719.10
5.4.210.0870.06719.20
5.4.200.0730.05016.77
5.4.190.0830.05719.20
5.4.180.0830.05319.17
5.4.170.0670.05018.97
5.4.160.0730.06019.26
5.4.150.0670.07019.23
5.4.140.0570.05316.68
5.4.130.0530.05716.70
5.4.120.0530.05316.51
5.4.110.0600.04316.43
5.4.100.0600.05716.47
5.4.90.0570.05316.73
5.4.80.0770.05316.55
5.4.70.0800.05316.54
5.4.60.0730.04316.68
5.4.50.0730.05716.47
5.4.40.0870.05316.54
5.4.30.0800.05316.56
5.4.20.0670.05716.68
5.4.10.0730.06016.63
5.4.00.0730.05015.89
5.3.290.0770.05314.84
5.3.280.0900.05014.68
5.3.270.0800.05714.70
5.3.260.0630.05314.70
5.3.250.0800.05714.72
5.3.240.0930.05014.71
5.3.230.0930.05014.80
5.3.220.0870.06314.95
5.3.210.0900.04714.86
5.3.200.0670.06014.73
5.3.190.0870.05714.62
5.3.180.0670.06314.60
5.3.170.0770.05314.58
5.3.160.0830.05714.66
5.3.150.0670.05714.73
5.3.140.0770.05014.76
5.3.130.0600.05714.60
5.3.120.0730.04714.72
5.3.110.0700.06314.69
5.3.100.0630.06014.20
5.3.90.0870.03714.14
5.3.80.0630.06014.40
5.3.70.0670.05014.30
5.3.60.0870.05014.15
5.3.50.0570.06014.09
5.3.40.1000.05014.23
5.3.30.0630.05714.32
5.3.20.0630.06013.84
5.3.10.0500.05013.95
5.3.00.0730.05313.78
5.2.170.0630.04311.37
5.2.160.0670.04711.20
5.2.150.0570.05011.24
5.2.140.0600.04011.20
5.2.130.0670.03311.40
5.2.120.0530.04011.22
5.2.110.0530.05311.20
5.2.100.0670.04311.24
5.2.90.0570.03311.20
5.2.80.0730.04311.47
5.2.70.0630.04311.39
5.2.60.0470.04711.17
5.2.50.0770.04011.13
5.2.40.0530.04311.05
5.2.30.0530.04011.11
5.2.20.0630.04311.05
5.2.10.0330.04011.14
5.2.00.0330.04711.00
5.1.60.0330.04010.17
5.1.50.0370.03710.36
5.1.40.0500.03310.10
5.1.30.0500.03310.63
5.1.20.0430.04310.56
5.1.10.0370.04310.16
5.1.00.0430.03710.13
5.0.50.0270.0278.82
5.0.40.0270.0278.45
5.0.30.0200.0538.51
5.0.20.0200.0308.34
5.0.10.0330.0278.35
5.0.00.0130.0478.34
4.4.90.0230.0175.75
4.4.80.0200.0305.85
4.4.70.0270.0235.85
4.4.60.0330.0235.93
4.4.50.0270.0205.92
4.4.40.0170.0405.85
4.4.30.0230.0235.74
4.4.20.0230.0235.96
4.4.10.0200.0235.91
4.4.00.0170.0375.91
4.3.110.0130.0275.70
4.3.100.0270.0175.85
4.3.90.0170.0235.68
4.3.80.0270.0375.80
4.3.70.0230.0205.81
4.3.60.0230.0175.66
4.3.50.0270.0205.66
4.3.40.0270.0335.77
4.3.30.0070.0204.61
4.3.20.0130.0234.50
4.3.10.0170.0234.38
4.3.00.0100.0277.10

preferences:
56.98 ms | 401 KiB | 5 Q