3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $dom = new DOMDocument('1.0', 'ASCII'); $dom->appendChild($dom->createElement('foo')); $dom->documentElement->appendChild( $dom->createCDATASection( 'Foo &#228; ]]> &auml; bar äöü' ) ); $dom2 = new DOMDocument(); $dom2->substituteEntities = TRUE; $dom2->resolveExternals = TRUE; $dom2->loadXml($dom->saveXml()); $dom2->encoding= 'UTF-8'; $dom2->formatOutput(); $xpath = new DOMXpath($dom2); var_dump( $dom->saveXml(), $xpath->evaluate('string(/foo)') );
based on IEs0W
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined method DOMDocument::formatOutput() in /in/cX1lF:16 Stack trace: #0 {main} thrown in /in/cX1lF on line 16
Process exited with code 255.
Output for 5.0.0 - 5.6.28
Fatal error: Call to undefined method DOMDocument::formatOutput() in /in/cX1lF on line 16
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/cX1lF on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/cX1lF on line 2