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 git.master_jit, git.master
imgRight customs/2/pictures/home.png Une légende

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
52.89 ms | 405 KiB | 5 Q