3v4l.org

run code in 300+ PHP versions simultaneously
<?php $doc = new DOMDocument; $doc->loadHTML('<html><body id="x"><div id="y"></div></body></html>'); $body = $doc->getElementById('x'); $div = $doc->getElementById('y'); $body->removeChild($div); echo $doc->getElementById('y') ? $doc->getElementById('y')->tagName : 'null'; $div->setIdAttribute( 'id', true ); echo $doc->getElementById('y') ? $doc->getElementById('y')->tagName : 'null';
Output for 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.23, 7.4.0 - 7.4.11, 8.0.0alpha1 - rc2
divnull