3v4l.org

run code in 500+ PHP versions simultaneously
<?php $doc = Dom\HTMLDocument::createFromString( '<!DOCTYPE html><p class="a b">one</p><p class="b">two</p>' ); foreach (['.a, .b', '.a, .b, .a.b', ':is(.a, .b)'] as $selector) { $texts = []; foreach ($doc->querySelectorAll($selector) as $element) { $texts[] = $element->textContent; } echo $selector, ' => ', implode(' ', $texts), "\n"; }
Output for 8.2.0 - 8.2.34, 8.3.0 - 8.3.35
Fatal error: Uncaught Error: Class "Dom\HTMLDocument" not found in /in/11SH2:3 Stack trace: #0 {main} thrown in /in/11SH2 on line 3
Process exited with code 255.
Output for 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
.a, .b => one one two .a, .b, .a.b => one one one two :is(.a, .b) => one two

preferences:
31.12 ms | 1140 KiB | 9 Q