3v4l.org

run code in 300+ PHP versions simultaneously
<?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.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
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.4.2 - 5.4.45, 5.5.24 - 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.

preferences:
129.02 ms | 402 KiB | 226 Q