3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test( $input) { $doc = new DOMDocument; $doc->loadHTML( $input); $p = $doc->getElementsByTagName('p')->item(0); $children = $p->childNodes; $img_found = false; $error = false; foreach( $children as $child) { if( $child->nodeType == XML_TEXT_NODE && !$img_found) { // Text before the image, OK, continue on continue; } if( $child->nodeType == XML_ELEMENT_NODE) { if( !($child->tagName == 'img')) { // echo "Invalid HTML element found"; $error = true; } else { $img_found = true; } } else { // echo "Invalid node type!"; $error = true; } } if( $img_found && !$error) { echo 'ok' . "\n"; } else { echo 'NOT ok' . "\n"; } } $input = '<p><img src="#" /></p>'; // ok test( $input); $input = '<p><img src="#" /><img src="#" /></p>'; // ok test( $input); $input = '<p>xxx<img src="#" /></p>'; // ok test( $input); $input = '<p><img src="#" />xxx</p>'; // NOT ok test( $input);

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.0100.00616.38
8.3.50.0210.00717.42
8.3.40.0070.00719.02
8.3.30.0000.01418.84
8.3.20.0030.00518.87
8.3.10.0060.00320.83
8.3.00.0030.00717.63
8.2.180.0090.00625.92
8.2.170.0140.00022.96
8.2.160.0070.00720.65
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0000.00819.52
8.2.110.0130.00620.73
8.2.100.0000.01318.16
8.2.90.0060.00318.00
8.2.80.0000.00818.18
8.2.70.0080.00017.61
8.2.60.0080.00017.75
8.2.50.0030.00517.88
8.2.40.0090.00417.63
8.2.30.0090.00017.93
8.2.20.0060.00319.57
8.2.10.0000.00717.93
8.2.00.0000.00717.96
8.1.270.0000.00724.66
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0060.00321.14
8.1.230.0110.00019.22
8.1.220.0040.00418.03
8.1.210.0040.00418.77
8.1.200.0060.00317.63
8.1.190.0050.00317.48
8.1.180.0000.01218.10
8.1.170.0000.00917.77
8.1.160.0000.00719.08
8.1.150.0040.00418.79
8.1.140.0040.00419.07
8.1.130.0000.00717.91
8.1.120.0040.00417.57
8.1.110.0000.00717.66
8.1.100.0070.00017.58
8.1.90.0030.00517.69
8.1.80.0040.00417.71
8.1.70.0070.00017.56
8.1.60.0050.00217.80
8.1.50.0070.00017.61
8.1.40.0000.00917.72
8.1.30.0000.00817.78
8.1.20.0080.00017.84
8.1.10.0040.00417.77
8.1.00.0040.00417.60
8.0.300.0030.00521.81
8.0.290.0000.00716.88
8.0.280.0040.00418.23
8.0.270.0000.00818.11
8.0.260.0060.00016.95
8.0.250.0060.00317.15
8.0.240.0000.00817.19
8.0.230.0070.00017.20
8.0.220.0000.00717.09
8.0.210.0050.00217.12
8.0.200.0030.00317.18
8.0.190.0030.00517.20
8.0.180.0050.00217.16
8.0.170.0030.00617.08
8.0.160.0040.00417.07
8.0.150.0060.00317.18
8.0.140.0050.00317.02
8.0.130.0000.00513.53
8.0.120.0040.00416.99
8.0.110.0040.00416.91
8.0.100.0050.00217.07
8.0.90.0000.00717.16
8.0.80.0110.00617.13
8.0.70.0000.00716.99
8.0.60.0030.00516.97
8.0.50.0040.00317.08
8.0.30.0090.00917.24
8.0.20.0150.00817.36
8.0.10.0070.00017.16
8.0.00.0150.00616.91
7.4.330.0020.00213.16
7.4.320.0000.00616.80
7.4.300.0070.00016.65
7.4.290.0060.00316.70
7.4.280.0000.00716.71
7.4.270.0040.00416.81
7.4.260.0000.00613.41
7.4.250.0000.00816.83
7.4.240.0040.00416.82
7.4.230.0000.00816.60
7.4.220.0070.01016.69
7.4.210.0060.01116.72
7.4.200.0030.00316.83
7.4.190.0000.00716.97
7.4.160.0040.01216.54
7.4.150.0150.00316.77
7.4.140.0080.01016.74
7.4.130.0090.01116.75
7.4.120.0090.00816.57
7.4.110.0130.01016.77
7.4.100.0080.00816.65
7.4.90.0180.00016.79
7.4.80.0090.00919.39
7.4.70.0140.00416.71
7.4.60.0100.00616.74
7.4.50.0040.00916.46
7.4.40.0090.00616.56
7.4.30.0090.00616.59
7.4.00.0030.01015.11
7.3.330.0060.00013.43
7.3.320.0060.00013.38
7.3.310.0050.00216.61
7.3.300.0070.00016.45
7.3.290.0080.00816.48
7.3.280.0150.00516.63
7.3.270.0060.01216.55
7.3.260.0130.00416.73
7.3.250.0110.01116.80
7.3.240.0130.00316.66
7.3.230.0140.00516.84
7.3.210.0120.00416.69
7.3.200.0060.01216.54
7.3.190.0160.00016.52
7.3.180.0090.00616.75
7.3.170.0080.00816.71
7.3.160.0060.00916.89
7.3.120.0100.00314.93
7.3.10.0090.00916.75
7.3.00.0030.01016.77
7.2.330.0070.01017.11
7.2.320.0120.01116.96
7.2.310.0080.01116.66
7.2.300.0070.01516.99
7.2.290.0130.00716.78
7.2.130.0070.01116.82
7.2.120.0070.01017.05
7.2.110.0070.00417.16
7.2.100.0060.01216.91
7.2.90.0070.00317.09
7.2.80.0030.01217.17
7.2.70.0040.01116.99
7.2.60.0060.00717.01
7.2.50.0040.00717.03
7.2.40.0000.01616.77
7.2.30.0040.01117.19
7.2.20.0100.00617.00
7.2.10.0080.00317.20
7.2.00.0050.00918.25
7.1.250.0060.00915.68
7.1.200.0040.00916.04
7.1.100.0030.00917.90
7.1.70.0050.00517.00
7.1.60.0100.01419.40
7.1.50.0100.01017.21
7.1.00.0100.05022.48
7.0.200.0040.00416.56
7.0.140.0130.06322.09
7.0.120.0000.03722.00
7.0.60.0070.06720.01
7.0.50.0000.04318.01
7.0.40.0070.06720.22
7.0.30.0470.04020.14
7.0.20.0200.06320.22
7.0.10.0000.06020.42
7.0.00.0130.05320.14
5.6.280.0000.07721.11
5.6.210.0100.06720.83
5.6.200.0130.04018.25
5.6.190.0170.07320.68
5.6.180.4100.03720.53
5.6.170.0330.07720.59
5.6.160.0070.08720.60
5.6.150.0000.04718.23
5.6.140.0070.06718.21
5.6.130.0100.03718.35
5.6.120.0130.08021.17
5.6.110.0070.05721.04
5.6.100.0070.08021.01
5.6.90.0070.05721.05
5.6.80.0130.08020.57
5.5.350.0100.05020.45
5.5.340.0030.05718.01
5.5.330.0170.07720.37
5.5.320.0200.08720.38
5.5.310.0300.04720.58
5.5.300.0170.06018.09
5.5.290.0030.05718.08
5.5.280.0070.08020.96
5.5.270.0000.06720.84
5.5.260.0230.05320.78
5.5.250.0070.08320.70
5.5.240.3830.04320.16
5.4.450.0070.04319.54
5.4.440.0000.06019.26
5.4.430.0030.05319.54
5.4.420.0070.04719.55
5.4.410.0000.06719.12
5.4.400.0100.05719.20
5.4.390.0030.04019.23
5.4.380.0030.06319.07
5.4.370.0030.07719.26
5.4.360.0100.04019.29
5.4.350.0070.07718.97
5.4.340.0100.07019.18
5.4.320.0030.04019.22
5.4.310.0030.03719.05
5.4.300.0130.06319.31
5.4.290.0000.04718.95
5.4.280.0070.08019.19
5.4.270.0170.04319.05
5.4.260.0000.08019.32
5.4.250.0070.06319.07
5.4.240.0070.07719.30
5.4.230.0130.07018.91
5.4.220.0100.07019.04
5.4.210.0030.06719.33
5.4.200.0170.06719.37
5.4.190.0130.04019.27
5.4.180.0030.04319.37
5.4.170.0000.04019.31
5.4.160.0130.05718.93
5.4.150.0000.04318.91
5.4.140.0070.05016.57
5.4.130.0030.03716.58
5.4.120.0000.04316.47
5.4.110.0170.05316.60
5.4.100.0070.05016.49
5.4.90.0070.04016.80
5.4.80.0030.05716.68
5.4.70.0100.06716.79
5.4.60.0030.04016.59
5.4.50.0030.07316.57
5.4.40.0030.06016.50
5.4.30.0070.04016.54
5.4.20.0000.05316.46
5.4.10.0130.04016.49
5.4.00.0000.04316.03
5.3.290.0030.04314.63
5.3.280.0100.07714.73
5.3.270.0000.04714.73
5.3.260.0000.04714.75
5.3.250.0000.04014.75
5.3.240.0070.03714.60
5.3.230.0000.04014.61
5.3.220.0000.04014.70
5.3.210.0030.04014.66
5.3.200.0130.03014.68
5.3.190.0000.07714.69
5.3.180.0070.06014.71
5.3.170.0100.07314.55
5.3.160.0000.04314.68
5.3.150.0100.07014.57
5.3.140.0030.07314.52
5.3.130.0030.04014.68
5.3.120.0030.04014.63
5.3.110.0030.04314.67
5.3.100.0030.06314.15
5.3.90.0030.08014.14
5.3.80.0170.04714.15
5.3.70.0100.05014.10
5.3.60.0070.04714.11
5.3.50.0130.06714.08
5.3.40.0130.06714.07
5.3.30.0130.06713.89
5.3.20.0230.05713.69
5.3.10.0070.07013.65
5.3.00.0070.04013.77
5.2.170.0000.04311.28
5.2.160.0030.06311.25
5.2.150.0070.03711.24
5.2.140.0030.06011.27
5.2.130.0030.05011.33
5.2.120.0000.04311.17
5.2.110.0100.06011.25
5.2.100.0130.05311.23
5.2.90.0000.05311.20
5.2.80.0030.04011.23
5.2.70.0030.03711.22
5.2.60.0100.04011.18
5.2.50.0070.06311.14
5.2.40.0030.06011.12
5.2.30.0030.04010.93
5.2.20.0100.05311.00
5.2.10.0100.04310.89
5.2.00.0000.06010.84
5.1.60.0000.05310.09
5.1.50.0070.03310.09
5.1.40.0000.05710.04
5.1.30.0030.04010.29
5.1.20.0030.06010.48
5.1.10.0100.02310.11
5.1.00.0070.05710.29
5.0.50.0070.0338.62
5.0.40.0070.0378.54
5.0.30.0030.0338.34
5.0.20.0100.0338.37
5.0.10.0070.0438.27
5.0.00.0100.0608.29
4.4.90.0070.0337.95
4.4.80.0030.0377.95
4.4.70.0030.0377.95
4.4.60.0070.0337.95
4.4.50.0000.0307.95
4.4.40.0000.0307.95
4.4.30.0000.0207.95
4.4.20.0030.0337.95
4.4.10.0070.0107.95
4.4.00.0000.0307.95
4.3.110.0070.0177.95
4.3.100.0030.0337.95
4.3.90.0000.0207.95
4.3.80.0000.0577.95
4.3.70.0000.0237.95
4.3.60.0070.0107.95
4.3.50.0030.0137.95
4.3.40.0030.0537.95
4.3.30.0030.0337.95
4.3.20.0000.0407.95
4.3.10.0030.0277.95
4.3.00.0070.0177.95

preferences:
73.75 ms | 400 KiB | 5 Q