3v4l.org

run code in 300+ PHP versions simultaneously
<?php const STAR_PROTECTOR = '__zqh6vxfbk3cg__'; function load($html) { $html = str_replace('*', STAR_PROTECTOR, $html); $document = <<<EOD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head> <body>!html</body> </html> EOD; // PHP's \DOMDocument serialization adds extra whitespace when the markup // of the wrapping document contains newlines, so ensure we remove all // newlines before injecting the actual HTML body to be processed. $document = strtr($document, ["\n" => '', '!html' => $html]); $dom = new \DOMDocument(); // Ignore warnings during HTML soup loading. @$dom->loadHTML($document); return $dom; } function simulate_filter_html_parsing(string $input) { print "-----\n$input\n-----\n"; $parsed_nodes = load($input)->getElementsByTagName('body')->item(0)->childNodes; foreach ($parsed_nodes as $node) { // ⚠️ See @larowlan's https://www.drupal.org/project/drupal/issues/3280602#comment-14517052 comment if ($node->nodeType !== XML_ELEMENT_NODE) { // Skip the empty text nodes inside tags. continue; } print 'tag: '; var_dump($node->tagName); foreach ($node->attributes as $name => $attribute) { // Put back any trailing * on wildcard attribute name. $name = str_replace(STAR_PROTECTOR, '*', $name); // Put back any trailing * on wildcard attribute value and parse out // the allowed attribute values. $allowed_attribute_values = preg_split('/\s+/', str_replace(STAR_PROTECTOR, '*', $attribute->value), -1, PREG_SPLIT_NO_EMPTY); print 'attr: '; var_dump($name); // if ($attr-) if (!empty($allowed_attribute_values)) { print 'attr values: '; var_dump($allowed_attribute_values); } } } print "\n\n"; } // ⚠️ Uncomment this if you want to convince yourself this really is running for all PHP versions // print phpversion() . "\n"; simulate_filter_html_parsing('<foo data-*>'); simulate_filter_html_parsing('<foo data-*="foo bar">'); simulate_filter_html_parsing('<__preprocessed-global-attribute__ data-*="foo bar">'); // ⚠️ This is the specific example @larowlan cited at https://www.drupal.org/project/drupal/issues/3280602#comment-14517052 simulate_filter_html_parsing('<__preprocessed-wildcard-text-container__ class="text-align-left text-align-center text-align-right text-align-justify" />'); // ⚠️ 3vl.org unfortunately has disabled phpinfo for security reasons… so we cannot check the libxml version //var_dump(phpinfo(INFO_MODULES));

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.5.10.0110.00718.99
8.5.00.0110.01220.57
8.4.160.0150.01023.96
8.4.150.0020.00114.05
8.4.140.0150.00818.07
8.4.130.0120.00918.21
8.4.120.0040.00524.44
8.4.110.0050.00419.02
8.4.100.0110.01019.32
8.4.90.0130.00722.78
8.4.80.0070.00619.23
8.4.70.0030.00518.98
8.4.60.0110.01019.16
8.4.50.0090.01118.25
8.4.40.0100.01019.77
8.4.30.0140.00720.89
8.4.20.0140.00719.89
8.4.10.0030.00722.16
8.3.280.0110.01018.88
8.3.270.0120.00917.00
8.3.260.0080.00916.98
8.3.250.0100.00217.18
8.3.240.0130.00817.49
8.3.230.0050.00417.00
8.3.220.0130.00519.41
8.3.210.0090.00617.16
8.3.200.0050.00417.25
8.3.190.0090.00917.43
8.3.180.0060.01017.18
8.3.170.0100.01019.25
8.3.160.0030.01717.14
8.3.150.0080.01120.96
8.3.140.0060.00317.24
8.3.130.0140.00718.94
8.3.120.0070.00319.15
8.3.110.0040.01520.94
8.3.100.0040.00417.29
8.3.90.0080.00026.77
8.3.80.0070.00317.13
8.3.70.0110.00717.13
8.3.60.0110.01118.80
8.3.50.0120.00620.77
8.3.40.0160.00619.36
8.3.30.0080.00819.71
8.3.20.0060.00324.18
8.3.10.0040.00424.66
8.3.00.0000.00826.16
8.2.290.0070.00320.59
8.2.280.0070.00218.98
8.2.270.0070.01317.27
8.2.260.0060.00318.95
8.2.250.0040.00419.08
8.2.240.0040.00417.80
8.2.230.0080.00022.58
8.2.220.0030.00624.06
8.2.210.0080.00026.77
8.2.200.0030.00618.79
8.2.190.0060.01317.00
8.2.180.0060.01025.92
8.2.170.0130.00319.41
8.2.160.0110.00722.96
8.2.150.0040.00425.66
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0060.00326.16
8.2.110.0090.00020.63
8.2.100.0040.00818.53
8.2.90.0060.00318.13
8.2.80.0050.00319.33
8.2.70.0000.00818.00
8.2.60.0030.00518.18
8.2.50.0030.00518.29
8.2.40.0050.00318.34
8.2.30.0000.00818.67
8.2.20.0040.00420.73
8.2.10.0050.00218.32
8.2.00.0030.00619.69
8.1.330.0110.00822.23
8.1.320.0110.00817.05
8.1.310.0000.00817.25
8.1.300.0100.01018.60
8.1.290.0110.00030.84
8.1.280.0030.01225.92
8.1.270.0200.00023.89
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0000.01122.41
8.1.230.0040.00822.33
8.1.220.0040.00417.90
8.1.210.0000.00918.77
8.1.200.0080.00417.73
8.1.190.0030.00517.60
8.1.180.0080.00018.10
8.1.170.0040.00418.01
8.1.160.0040.00419.17
8.1.150.0050.00318.95
8.1.140.0040.00417.87
8.1.130.0040.00419.23
8.1.120.0000.00717.87
8.1.110.0040.00417.82
8.1.100.0000.00817.86
8.1.90.0050.00217.91
8.1.80.0040.00417.71
8.1.70.0000.00717.79
8.1.60.0280.00917.93
8.1.50.0260.00517.85
8.1.40.0210.01017.81
8.1.30.0270.00418.05
8.1.20.0270.00418.04
8.1.10.0160.00517.78
8.1.00.0210.00717.68
8.0.300.0000.00918.99
8.0.290.0050.00317.38
8.0.280.0040.00418.69
8.0.270.0080.00017.32
8.0.260.0000.00718.73
8.0.250.0040.00417.39
8.0.240.0040.00417.45
8.0.230.0000.00817.43
8.0.220.0070.00017.27
8.0.210.0030.00317.34
8.0.200.0070.00017.39
8.0.190.0160.00617.14
8.0.180.0060.00617.21
8.0.170.0030.00917.26
8.0.160.0100.00017.27
8.0.150.0090.00317.30
8.0.140.0070.00417.20
8.0.130.0100.00717.05
8.0.120.0090.00516.99
8.0.110.0090.00617.19
8.0.100.0080.00317.25
8.0.90.0110.00317.17
8.0.80.0120.00416.99
8.0.70.0100.00517.31
8.0.60.0080.00917.25
8.0.50.0120.00417.17
8.0.30.0040.01217.27
8.0.20.0080.00817.19
8.0.10.0230.00017.33
7.4.330.0030.00315.55
7.4.320.0040.00416.88
7.4.300.0030.00517.14
7.4.290.0180.00316.45
7.4.280.0070.00716.77
7.4.270.0090.01016.90
7.4.260.0090.00916.69
7.4.250.0210.00316.88
7.4.240.0130.00517.00
7.4.230.0190.00016.86
7.4.220.0170.00316.48
7.4.210.0110.00516.58
7.4.200.0070.00516.50
7.4.190.0080.00816.54
7.4.180.0060.00916.75
7.4.160.0070.00816.87
7.4.150.0140.00716.75
7.4.140.0050.01016.67
7.4.130.0100.00416.97
7.4.120.0100.00516.77
7.4.110.0130.00016.84
7.4.100.0110.01116.66
7.4.90.0180.00016.69
7.4.80.0130.00716.87
7.4.70.0050.01017.00
7.4.60.0150.00816.81
7.4.50.0270.00016.72
7.4.40.0120.00916.76
7.4.30.0140.00516.48
7.4.20.0100.00316.93
7.4.10.0140.00316.50
7.4.00.0140.00516.76

preferences:
40.51 ms | 403 KiB | 5 Q