3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test( $input) { $doc = new DOMDocument; $doc->loadHTML( $input); $p = $doc->getElementsByTagName('img')->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 = ' <a href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/Interschool-championship.gif"><a href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0889.jpg"><img class="aligncenter size-full wp-image-1928" alt="sports championship competition" src="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0889.jpg" width="1024" height="768" /></a><a href="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0830.jpg"><img class="aligncenter size-full wp-image-1929" alt="sports championship competition" src="http://inorbit.in/whitefield/wp-content/uploads/sites/4/2014/06/IMG_0830.jpg" width="1024" height="768" /></a></a>'; // 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.0180.00416.88
8.3.50.0110.00422.18
8.3.40.0090.00619.07
8.3.30.0070.00719.35
8.3.20.0060.00320.29
8.3.10.0060.00323.94
8.3.00.0050.00321.05
8.2.180.0090.00616.75
8.2.170.0120.00922.96
8.2.160.0110.01120.63
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0000.00820.84
8.2.110.0000.00822.33
8.2.100.0040.00718.16
8.2.90.0040.00419.52
8.2.80.0030.00517.97
8.2.70.0090.00017.63
8.2.60.0060.00318.05
8.2.50.0050.00518.07
8.2.40.0040.00421.30
8.2.30.0000.00718.53
8.2.20.0050.00317.86
8.2.10.0000.00718.39
8.2.00.0040.00417.88
8.1.280.0070.01425.92
8.1.270.0080.00024.01
8.1.260.0060.00326.35
8.1.250.0050.00328.09
8.1.240.0040.00424.26
8.1.230.0080.00419.41
8.1.220.0000.00817.93
8.1.210.0050.00318.77
8.1.200.0030.00717.35
8.1.190.0080.00017.35
8.1.180.0080.00018.10
8.1.170.0060.00318.84
8.1.160.0040.00422.28
8.1.150.0000.00818.80
8.1.140.0000.00717.74
8.1.130.0080.00018.01
8.1.120.0000.00717.58
8.1.110.0050.00217.70
8.1.100.0000.00817.60
8.1.90.0000.00717.64
8.1.80.0030.00517.62
8.1.70.0000.00717.67
8.1.60.0060.00317.75
8.1.50.0080.00017.79
8.1.40.0000.00817.76
8.1.30.0030.00617.99
8.1.20.0000.00817.89
8.1.10.0000.00817.85
8.1.00.0030.00617.62
8.0.300.0060.00318.77
8.0.290.0000.00817.54
8.0.280.0000.00718.61
8.0.270.0070.00017.55
8.0.260.0000.00617.48
8.0.250.0030.00317.25
8.0.240.0050.00317.18
8.0.230.0000.00717.24
8.0.220.0000.00817.15
8.0.210.0050.00317.10
8.0.200.0000.00617.29
8.0.190.0000.00817.25
8.0.180.0040.00417.21
8.0.170.0030.00617.26
8.0.160.0050.00317.11
8.0.150.0000.00716.98
8.0.140.0000.00717.07
8.0.130.0030.00313.57
8.0.120.0040.00417.21
8.0.110.0040.00417.10
8.0.100.0050.00317.21
8.0.90.0040.00417.02
8.0.80.0040.01117.19
8.0.70.0040.00417.02
8.0.60.0000.00717.00
8.0.50.0000.00817.26
8.0.30.0120.00717.46
8.0.20.0110.01017.40
8.0.10.0000.00717.09
8.0.00.0090.00817.14
7.4.330.0000.00515.00
7.4.320.0050.00316.76
7.4.300.0000.00616.83
7.4.290.0000.00716.74
7.4.280.0030.00516.71
7.4.270.0070.00016.82
7.4.260.0030.00316.70
7.4.250.0040.00416.71
7.4.240.0040.00416.86
7.4.230.0040.00416.94
7.4.220.0060.01816.82
7.4.210.0100.00716.72
7.4.200.0000.00716.92
7.4.190.0000.00716.71
7.4.160.0100.00616.64
7.4.150.0070.01117.40
7.4.140.0110.00917.86
7.4.130.0110.00816.85
7.4.120.0150.00316.86
7.4.110.0060.01316.78
7.4.100.0060.01516.86
7.4.90.0120.00616.69
7.4.80.0130.00319.39
7.4.70.0150.00816.81
7.4.60.0180.00017.00
7.4.50.0060.00316.90
7.4.40.0120.00316.87
7.4.30.0070.01016.84
7.4.00.0100.00815.00
7.3.330.0000.00513.52
7.3.320.0000.00513.48
7.3.310.0070.00016.62
7.3.300.0030.00316.61
7.3.290.0030.01216.63
7.3.280.0070.01316.66
7.3.270.0090.00917.40
7.3.260.0040.01416.59
7.3.250.0120.00716.77
7.3.240.0030.01316.53
7.3.230.0100.01316.77
7.3.210.0180.00316.68
7.3.200.0030.01719.39
7.3.190.0090.00916.79
7.3.180.0110.00716.75
7.3.170.0000.01516.58
7.3.160.0050.01016.71
7.3.120.0050.01415.09
7.3.110.0030.01214.91
7.3.100.0070.01014.78
7.3.90.0100.00214.94
7.3.80.0050.00715.01
7.3.70.0090.00514.98
7.3.60.0020.01114.99
7.3.50.0110.00515.02
7.3.40.0070.00714.69
7.3.30.0040.01014.95
7.3.20.0040.00816.81
7.3.10.0080.00616.77
7.3.00.0030.01016.88
7.2.330.0070.01116.97
7.2.320.0070.01016.96
7.2.310.0060.01716.93
7.2.300.0100.00616.66
7.2.290.0160.00716.74
7.2.250.0070.01415.03
7.2.240.0070.00815.13
7.2.230.0000.01515.13
7.2.220.0070.00715.34
7.2.210.0090.00915.20
7.2.200.0050.00915.13
7.2.190.0100.00315.23
7.2.180.0050.01215.07
7.2.170.0050.01015.05
7.2.160.0000.01515.23
7.2.150.0100.00617.13
7.2.140.0070.01116.84
7.2.130.0070.01117.08
7.2.120.0030.01016.77
7.2.110.0060.00916.67
7.2.100.0120.00417.23
7.2.90.0040.00816.89
7.2.80.0030.01316.89
7.2.70.0060.00917.28
7.2.60.0000.01017.02
7.2.50.0030.01016.90
7.2.40.0040.01116.63
7.2.30.0070.00717.10
7.2.20.0070.00716.85
7.2.10.0110.00416.82
7.2.00.0040.01116.80
7.1.330.0050.00916.02
7.1.320.0060.00815.77
7.1.310.0130.00315.91
7.1.300.0060.00516.00
7.1.290.0060.00715.73
7.1.280.0080.00815.81
7.1.270.0050.01215.90
7.1.260.0090.00615.94
7.1.250.0030.01016.08
7.1.70.0000.01016.95
7.1.60.0130.01019.46
7.1.50.0040.01417.08
7.1.00.0000.10022.55
7.0.200.0000.00716.84
7.0.140.0000.07722.11
7.0.60.0100.06720.12
7.0.50.0000.04718.13
7.0.40.0070.06020.27
7.0.30.0230.08720.34
7.0.20.0230.06020.25
7.0.10.0000.04720.26
7.0.00.0070.04020.30
5.6.280.0070.07021.20
5.6.210.0030.04720.52
5.6.200.0070.03718.35
5.6.190.0130.03320.71
5.6.180.0170.08020.54
5.6.170.0300.04320.65
5.6.160.0170.07320.56
5.6.150.0100.07718.33
5.6.140.0100.04718.34
5.6.130.0030.05018.42
5.6.120.0070.08321.05
5.6.110.0070.08321.19
5.6.100.0100.07721.19
5.6.90.0100.05321.13
5.6.80.0000.05320.41
5.5.350.4370.03720.43
5.5.340.0030.04018.06
5.5.330.0170.08020.33
5.5.320.0270.04720.44
5.5.310.0470.06720.36
5.5.300.0070.06718.11
5.5.290.0070.03718.15
5.5.280.0070.06320.70
5.5.270.0030.08320.84
5.5.260.0100.08020.94
5.5.250.0130.08020.66
5.5.240.0000.06320.39
5.4.450.0000.07019.50
5.4.440.0030.07719.40
5.4.430.0070.07019.33
5.4.420.0030.05319.71
5.4.410.0070.07319.32
5.4.400.0070.07019.39
5.4.390.0030.07319.02
5.4.380.0000.05319.30
5.4.370.0000.07719.39
5.4.360.0100.07319.14
5.4.350.0070.06719.32
5.4.340.0070.07719.17
5.4.320.0030.04319.12
5.4.310.0030.04319.16
5.4.300.0000.06719.13
5.4.290.0030.06019.21
5.4.280.0000.08019.39
5.4.270.0030.07719.16
5.4.260.0030.07718.99
5.4.250.0100.07319.31
5.4.240.0100.06319.22
5.4.230.0070.05719.27
5.4.220.0030.06319.27
5.4.210.0100.06719.11
5.4.200.0070.04719.29
5.4.190.0030.04719.12
5.4.180.0000.08019.13
5.4.170.0070.05319.31
5.4.160.0130.03319.25
5.4.150.0100.06719.19
5.4.140.0030.04016.52
5.4.130.0000.04716.79
5.4.120.0030.06716.43
5.4.110.0030.07316.52
5.4.100.0000.07716.58
5.4.90.0070.05716.51
5.4.80.0070.06716.38
5.4.70.0030.05316.41
5.4.60.0030.04716.66
5.4.50.0030.04316.51
5.4.40.0070.04016.55
5.4.30.0030.07316.55
5.4.20.0030.07316.66
5.4.10.0070.07316.48
5.4.00.0030.07315.93
5.3.290.0000.05314.82
5.3.280.0070.05314.59
5.3.270.0000.07714.77
5.3.260.0070.07714.60
5.3.250.0070.07014.76
5.3.240.0030.06714.68
5.3.230.0100.05314.59
5.3.220.0000.07014.71
5.3.210.0000.05014.77
5.3.200.0000.07714.88
5.3.190.0030.06014.63
5.3.180.0030.07714.64
5.3.170.0070.05714.61
5.3.160.0030.08014.72
5.3.150.0030.04714.80
5.3.140.0030.07314.63
5.3.130.0070.07314.69
5.3.120.0000.07314.63
5.3.110.0100.05714.61
5.3.100.0070.05714.09
5.3.90.0000.07314.11
5.3.80.0070.07314.03
5.3.70.0070.05714.18
5.3.60.0000.04014.06
5.3.50.0030.03313.96
5.3.40.0000.04314.09
5.3.30.0030.03714.17
5.3.20.0030.07014.02
5.3.10.0000.07313.81
5.3.00.0000.07313.80
5.2.170.0000.03312.91
5.2.160.0070.05312.91
5.2.150.0000.04012.91
5.2.140.0030.05712.91
5.2.130.0070.06012.91
5.2.120.0030.05012.91
5.2.110.0070.04712.91
5.2.100.0030.03712.91
5.2.90.0070.03312.91
5.2.80.0000.04012.91
5.2.70.0000.06312.91
5.2.60.0070.03712.91
5.2.50.0030.06012.91
5.2.40.0030.02712.91
5.2.30.0030.03712.91
5.2.20.0000.06012.91
5.2.10.0000.05012.91
5.2.00.0030.03712.91
5.1.60.0030.02312.91
5.1.50.0030.03712.91
5.1.40.0000.04012.91
5.1.30.0030.05712.91
5.1.20.0030.02712.91
5.1.10.0030.05312.91
5.1.00.0070.03312.91
5.0.50.0000.04312.91
5.0.40.0000.03012.91
5.0.30.0000.05712.91
5.0.20.0030.02712.91
5.0.10.0030.02312.91
5.0.00.0000.03312.91
4.4.90.0000.01712.91
4.4.80.0030.01712.91
4.4.70.0030.03012.91
4.4.60.0070.01312.91
4.4.50.0000.03312.91
4.4.40.0000.06012.91
4.4.30.0000.03312.91
4.4.20.0000.03712.91
4.4.10.0070.02312.91
4.4.00.0030.04712.91
4.3.110.0030.02012.91
4.3.100.0000.02712.91
4.3.90.0070.02012.91
4.3.80.0030.03312.91
4.3.70.0030.03012.91
4.3.60.0000.03312.91
4.3.50.0000.03312.91
4.3.40.0030.04312.91
4.3.30.0030.03012.91
4.3.20.0030.02712.91
4.3.10.0000.04012.91
4.3.00.0030.03312.91

preferences:
41.67 ms | 401 KiB | 5 Q