3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<DATA <p>Lorem Ipsum is simply dummy text</p> <p>Lorem Ipsum is <a href="http://www.google.com">simply</a> dummy text</p><a href="http://www.youtube.com/watch?v=DUQi_R4SgWo" target="_blank" rel="noopener">Check out the video here!</a>. <p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p> <a href="http://www.youtube.com/watch?v=A_6gNZCkajU" target="_blank" rel="noopener">Video here</a> <p>It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> DATA; # set up the DOM $dom = new DOMDocument(); $dom->loadHTML($html, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED); # set up the xpath $xpath = new DOMXPath($dom); # set up the regex $xpath->registerNamespace('php', 'http://php.net/xpath'); $xpath->registerPHPFunctions('match'); $links = $xpath->query("a[php:functionString('match', @href)]"); function match($href) { $regex = '~\?v=([^&]+)~'; $rc = preg_match($regex, $href, $matches); var_dump($matches[1]); return $rc; }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
Parse error: syntax error, unexpected token "match", expecting "(" in /in/041WD on line 19
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
string(11) "DUQi_R4SgWo" string(11) "A_6gNZCkajU"
Output for 5.3.0 - 5.3.29
Notice: Use of undefined constant LIBXML_HTML_NODEFDTD - assumed 'LIBXML_HTML_NODEFDTD' in /in/041WD on line 9 Notice: Use of undefined constant LIBXML_HTML_NOIMPLIED - assumed 'LIBXML_HTML_NOIMPLIED' in /in/041WD on line 9 Warning: DOMDocument::loadHTML() expects exactly 1 parameter, 2 given in /in/041WD on line 9
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.1, 5.1.3 - 5.1.6, 5.2.0 - 5.2.17
Notice: Use of undefined constant LIBXML_HTML_NODEFDTD - assumed 'LIBXML_HTML_NODEFDTD' in /in/041WD on line 9 Notice: Use of undefined constant LIBXML_HTML_NOIMPLIED - assumed 'LIBXML_HTML_NOIMPLIED' in /in/041WD on line 9 Warning: DOMDocument::loadHTML() expects exactly 1 parameter, 2 given in /in/041WD on line 9 Fatal error: Call to undefined method DOMXPath::registerPHPFunctions() in /in/041WD on line 16
Process exited with code 255.
Output for 5.1.2
Notice: Use of undefined constant LIBXML_HTML_NODEFDTD - assumed 'LIBXML_HTML_NODEFDTD' in /in/041WD on line 10 Notice: Use of undefined constant LIBXML_HTML_NOIMPLIED - assumed 'LIBXML_HTML_NOIMPLIED' in /in/041WD on line 10 Warning: DOMDocument::loadHTML() expects exactly 1 parameter, 2 given in /in/041WD on line 10 Fatal error: Call to undefined method DOMXPath::registerPHPFunctions() in /in/041WD on line 17
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.1, 4.4.3 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/041WD on line 8
Process exited with code 255.
Output for 4.4.2
Fatal error: Cannot instantiate non-existent class: domdocument in /in/041WD on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/041WD on line 8

preferences:
245.6 ms | 416 KiB | 5 Q