3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $content = '<iframe width="560" height="315" src="https://www.youtube.com/embed/W9k0OhJkjQ0" frameborder="0" allowfullscreen></iframe>'; $dom = new \DOMDocument( '1.0', 'UTF-8' ); // muted because malformed HTML cause warnings @$dom->loadXml( "<iframe_content>{$content}</iframe_content>" ); $domIframe = $dom->getElementsByTagName( 'iframe' ); // seems this iframe is not an iframe if ( ! $domIframe->length ) { echo 'No Iframe'; } /** @var \DOMElement $iframeNode */ $iframeNode = $domIframe->item( 0 ); $iframeNode->removeAttribute( 'width' ); $iframeNode->removeAttribute( 'height' ); echo $dom->saveHTML( $iframeNode );
Output for 7.0.0 - 7.2.0
No Iframe Fatal error: Uncaught Error: Call to a member function removeAttribute() on null in /in/MEdVQ:17 Stack trace: #0 {main} thrown in /in/MEdVQ on line 17
Process exited with code 255.
Output for 5.6.8 - 5.6.28
No Iframe Fatal error: Call to a member function removeAttribute() on null in /in/MEdVQ on line 17
Process exited with code 255.
Output for 5.3.18 - 5.5.35
No Iframe Fatal error: Call to a member function removeAttribute() on a non-object in /in/MEdVQ on line 17
Process exited with code 255.