3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<< HTML <article id="p73" class="p-quote"> Albert Einstein’s Quotes Collection <blockquote><p>Life is like riding a bicycle. To keep your balance, you must keep moving.</p></blockquote> <blockquote><p>Pure mathematics is, in its way, the poetry of logical ideas.</p></blockquote> <blockquote><p>Education is what remains after one has forgotten what one has learned in school.</p></blockquote> <blockquote><p>Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.</p></blockquote> <blockquote><p>Logic will get you from A to B. Imagination will take you everywhere.</p></blockquote> <blockquote><p>If you can’t explain it simply, you don’t understand it well enough.</p></blockquote> <blockquote><p>The difference between stupidity and genius is that genius has its limits.</p></blockquote> </article> HTML; class ExtractTag { private $doc = null; public function __construct($html) { $this->doc = new DomDocument(); $content = mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' ); @$this->doc->loadHTML($content); } private function getFirstTag($tag) { $elements = $this->doc->getElementsByTagName($tag); if (!$elements->count()) { throw new Exception('no elements found'); } return $elements->item(0); } private function printFirstTag($tag) { $firstTag = $this->getFirstTag($tag); echo $this->doc->saveHTML($firstTag); } public function print_image() { $this->printFirstTag('img'); } public function print_quote() { $this->printFirstTag('blockquote'); } } $dom = new ExtractTag($html); echo $dom->print_quote(); #Expect to see a <blockquote> echo $dom->print_image(); #Expect to see nothing since there is no <img> tag in the html!

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.4.130.0140.00719.22
8.4.120.0150.00524.37
8.4.110.0130.01018.21
8.4.100.0140.00518.05
8.4.90.0130.00720.95
8.4.80.0060.00921.21
8.4.70.0040.00420.89
8.4.60.0090.01218.96
8.4.50.0140.00818.55
8.4.40.0060.01320.06
8.4.30.0100.01022.82
8.4.20.0130.00718.89
8.4.10.0110.00020.16
8.3.260.0140.00616.95
8.3.250.0100.00619.26
8.3.240.0120.01017.36
8.3.230.0110.00816.79
8.3.220.0020.00819.25
8.3.210.0060.00318.83
8.3.200.0040.00617.23
8.3.190.0110.00917.28
8.3.180.0160.00418.91
8.3.170.0160.00319.54
8.3.160.0080.00017.41
8.3.150.0190.00019.55
8.3.140.0080.00019.54
8.3.130.0030.00917.14
8.3.120.0040.01119.24
8.3.110.0030.00619.10
8.3.100.0080.00019.03
8.3.90.0050.00326.77
8.3.80.0040.00417.13
8.3.70.0110.00717.25
8.3.60.0180.00317.00
8.3.50.0130.00822.20
8.3.40.0210.00019.04
8.3.30.0120.00419.21
8.3.20.0160.00322.15
8.3.10.0040.00420.54
8.3.00.0080.00023.73
8.2.290.0120.00716.92
8.2.280.0120.00818.86
8.2.270.0190.00017.31
8.2.260.0080.00819.13
8.2.250.0040.00417.50
8.2.240.0160.00319.25
8.2.230.0060.00320.94
8.2.220.0030.00624.06
8.2.210.0030.00626.77
8.2.200.0000.00917.13
8.2.190.0040.01517.00
8.2.180.0150.00016.88
8.2.170.0070.00722.96
8.2.160.0040.01121.33
8.2.150.0000.00924.18
8.2.140.0030.00524.66
8.2.130.0050.00326.16
8.2.120.0040.00421.41
8.2.110.0080.00321.24
8.2.100.0040.00818.28
8.2.90.0060.00318.11
8.2.80.0040.00419.36
8.2.70.0060.00318.26
8.2.60.0030.00518.47
8.2.50.0050.00318.10
8.2.40.0030.00619.76
8.2.30.0040.00419.57
8.2.20.0040.00418.38
8.2.10.0020.00519.80
8.2.00.0050.00219.55
8.1.330.0130.00716.78
8.1.320.0110.00916.66
8.1.310.0070.01118.64
8.1.300.0080.00416.53
8.1.290.0070.00430.84
8.1.280.0090.00625.92
8.1.270.0070.01122.43
8.1.260.0080.00026.35
8.1.250.0050.00328.09
8.1.240.0000.00922.28
8.1.230.0080.00421.18
8.1.220.0040.00418.04
8.1.210.0080.00019.21
8.1.200.0080.00417.73
8.1.190.0040.00817.60
8.1.180.0030.00618.10
8.1.170.0030.00518.71
8.1.160.0070.00019.18
8.1.150.0040.00419.39
8.1.140.0040.00419.09
8.1.130.0070.00020.61
8.1.120.0000.00817.73
8.1.110.0090.00317.66
8.1.100.0040.00417.72
8.1.90.0080.00017.80
8.1.80.0040.00417.74
8.1.70.0110.00017.79
8.1.60.0040.00417.85
8.1.50.0080.00017.90
8.1.40.0060.00317.86
8.1.30.0030.00517.95
8.1.20.0030.00717.98
8.1.10.0040.00717.85
8.1.00.0040.00417.82
8.0.300.0060.00320.34
8.0.290.0060.00317.13
8.0.280.0000.00818.78
8.0.270.0000.00717.57
8.0.260.0030.00318.68
8.0.250.0030.00317.29
8.0.240.0060.00317.36
8.0.230.0070.00017.33
8.0.220.0030.00317.17
8.0.210.0040.00417.25
8.0.200.0030.00317.26
8.0.190.0000.00817.30
8.0.180.0080.00017.29
8.0.170.0030.00517.21
8.0.160.0040.00417.29
8.0.150.0000.00817.16
8.0.140.0040.00417.23
8.0.130.0030.00313.70
8.0.120.0030.00517.27
8.0.110.0000.00817.21
8.0.100.0000.00717.32
8.0.90.0090.00017.32
8.0.80.0070.01417.18
8.0.70.0040.00417.08
8.0.60.0050.00217.26
8.0.50.0050.00217.12
8.0.30.0070.01017.34
8.0.20.0120.00617.15
8.0.10.0060.00317.44
8.0.00.0140.00517.06
7.4.330.0040.00415.55
7.4.320.0030.00316.98
7.4.300.0000.00616.91
7.4.290.0020.00516.97
7.4.280.0040.00416.74
7.4.270.0030.00316.91
7.4.260.0030.00317.00
7.4.250.0080.00016.84
7.4.240.0050.00216.83
7.4.230.0000.00716.69
7.4.220.0030.00316.66
7.4.210.0070.00817.00
7.4.200.0030.00316.83
7.4.140.0040.01917.86
7.4.130.0150.00316.89
7.4.120.0100.01416.93
7.4.110.0070.01316.89
7.4.100.0100.01116.84
7.4.90.0090.00916.87
7.4.80.0080.01119.39
7.4.70.0030.01416.61
7.4.60.0090.00616.89
7.4.50.0040.01416.71
7.4.40.0060.01016.68
7.4.00.0030.01315.05
7.3.330.0050.00013.61
7.3.320.0030.00313.62
7.3.310.0080.00016.70
7.3.300.0030.00316.54
7.3.290.0000.00816.63
7.3.280.0150.00316.77
7.3.260.0100.00916.72
7.3.230.0070.01116.87
7.3.210.0070.01116.83
7.3.200.0140.00716.64
7.3.190.0130.00916.72
7.3.180.0170.00016.73
7.3.170.0040.01916.70
7.3.160.0080.01416.80
7.3.70.0140.00514.93
7.3.60.0100.00714.82
7.3.50.0060.00915.03
7.3.40.0070.00315.04
7.3.30.0140.00014.90
7.3.20.0120.00914.83
7.3.10.0190.00914.97
7.3.00.0180.00315.11
7.2.330.0120.00617.21
7.2.320.0170.00017.02
7.2.310.0030.01416.70
7.2.300.0090.00917.01
7.2.290.0140.00316.68
7.2.200.0060.00615.22
7.2.190.0040.01115.29
7.2.180.0040.01115.04
7.2.170.0000.01115.24
7.2.160.0180.00615.12
7.2.150.0090.00615.21
7.2.140.0180.00915.49
7.2.130.0140.01415.50
7.2.120.0150.00315.31
7.2.110.0070.00715.34
7.2.100.0120.00615.42
7.2.90.0070.01015.07
7.2.80.0150.00015.39
7.2.70.0140.00715.28
7.2.60.0140.00615.13
7.2.50.0170.00415.32
7.2.40.0150.00715.25
7.2.30.0130.00615.34
7.2.20.0260.00315.34
7.2.10.0210.00715.31
7.2.00.0190.00815.18
7.1.300.0230.00314.03
7.1.290.0090.00613.94
7.1.280.0320.00914.12
7.1.270.0130.00614.11
7.1.260.0110.00814.07
7.1.250.0090.00613.98

preferences:
30.43 ms | 403 KiB | 5 Q