3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CustomDOMDocument extends DOMDocument { } function localScope() { $doc = new CustomDOMDocument; $doc->loadHtml('<p>Test123</p>'); $xpath = new DOMXPath($doc); return $xpath; } $doc = new CustomDOMDocument; $doc->loadHtml('<p>Test123</p>'); $xpath = new DOMXPath($doc); var_dump(get_class($xpath->document)); $xpath = new DOMXPath(new CustomDOMDocument); var_dump(get_class($xpath->document)); $xpath = localScope(); var_dump(get_class($xpath->document));

preferences:
54.74 ms | 407 KiB | 5 Q