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; ]]> bar äöü' ) ); $dom2 = new DOMDocument(); $dom2->substituteEntities = TRUE; $dom2->resolveExternals = TRUE; $dom2->encoding= 'UTF-8'; $dom2->loadXml($dom->saveXml()); $xpath = new DOMXpath($dom2); var_dump( $dom->saveXml(), $xpath->evaluate('string(/foo)') );
based on Rcom1
Output for 5.1.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
string(112) "<?xml version="1.0" encoding="ASCII"?> <foo><![CDATA[Foo &#228; ]]]]><![CDATA[> bar &#228;&#246;&#252;]]></foo> " string(37) "Foo &#228; ]]> bar &#228;&#246;&#252;"
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined method DOMXPath::evaluate() in /in/9IXm2 on line 20
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/9IXm2 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/9IXm2 on line 2