3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<'HTML' <div class="blockImg imgRight"> <img src="customs/2/pictures/home.png"> <figcaption>Une légende</figcaption> </div> HTML; $dom = \Dom\HTMLDocument::createFromString($html, LIBXML_NOERROR); $divNode = $dom->querySelector('div.blockImg'); $classList = $divNode?->classList; if ($divNode and $classList->contains('imgRight') || $classList->contains('imgLeft')) { $class = $classList->contains('imgRight') ? 'imgRight' : 'imgLeft'; $src = $divNode->querySelector('img')->getAttribute('src'); $caption = $divNode->querySelector('figcaption')->textContent; echo $class, PHP_EOL, $src, PHP_EOL, $caption, PHP_EOL; }
Output for 8.4.1 - 8.4.14, 8.4.16 - 8.4.18, 8.5.0 - 8.5.3
imgRight customs/2/pictures/home.png Une légende
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 8.1.32 - 8.1.34, 8.2.25 - 8.2.30, 8.3.5 - 8.3.27, 8.3.29 - 8.3.30
Fatal error: Uncaught Error: Class "Dom\HTMLDocument" not found in /in/NHjFs:10 Stack trace: #0 {main} thrown in /in/NHjFs on line 10
Process exited with code 255.
Output for 8.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.

preferences:
64.7 ms | 408 KiB | 5 Q