3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = '<?xml version="1.0" encoding="UTF-8"?><html> <head> <title>Waa?</title> </head> <body> <ul> <li><img src="http://i.mg" alt="waa?" /><li /></li> </ul> </body> </html>'; /* $doc = new DOMDocument('1.0', 'UTF-8'); $doc->resolveExternals = true; $doc->loadXML($xml); $doc->validate(); */ $root = 'html'; $systemId = "http://office.react.nl/~arjen/php/xhtml1-transitional.dtd"; $creator = new DOMImplementation; $doctype = $creator->createDocumentType($root, null, $systemId); $new = $creator->createDocument(null, null, $doctype); $new->encoding = "utf-8"; $new->resolveExternals = true; var_dump($new->doctype === $doctype); $new->loadXML($xml); var_dump($new->doctype === $doctype); $new->validate();
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: DOMImplementation::createDocumentType(): Passing null to parameter #2 ($publicId) of type string is deprecated in /in/hrYHn on line 24 Deprecated: DOMImplementation::createDocument(): Passing null to parameter #2 ($qualifiedName) of type string is deprecated in /in/hrYHn on line 25 bool(true) bool(false) Warning: DOMDocument::validate(): no DTD found! in /in/hrYHn on line 31
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
bool(true) bool(false) Warning: DOMDocument::validate(): no DTD found! in /in/hrYHn on line 31
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
bool(true) bool(false) Notice: DOMDocument::validate(): No DTD given in XML-Document in /in/hrYHn on line 31 Warning: DOMDocument::validate(): no DTD found! in /in/hrYHn on line 31
Output for 5.0.0 - 5.0.5
bool(true) bool(false) Notice: DOMDocument::validate(): No DTD given in XML-Document in /in/hrYHn on line 31 Warning: no DTD found! in /in/hrYHn on line 31
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domimplementation in /in/hrYHn on line 23
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domimplementation in /in/hrYHn on line 23

preferences:
295.36 ms | 401 KiB | 452 Q