3v4l.org

run code in 300+ PHP versions simultaneously
$xml = <<<XML <?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE markables SYSTEM "markables.dtd"> <markables> <markable id="markable_1" atrib="yes" span="word_1..word_4"> </markable> <markable id="markable_2" atrib="no" span="word_6..word_7"> </markable> <markable id="markable_3" atrib="yes" span="word_10..word_24"> </markable> </markables> XML; <?php $doc = new DOMDocument(); $doc->loadXML($xml); $xp = new DOMXPath($doc); foreach($xp->query('/markables/markable/@atrib[. != "yes"]') as $attrib) { $attrib->nodeValue = 'yes'; } echo $doc->saveXML();
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
$xml = <<<XML <?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE markables SYSTEM "markables.dtd"> <markables> <markable id="markable_1" atrib="yes" span="word_1..word_4"> </markable> <markable id="markable_2" atrib="no" span="word_6..word_7"> </markable> <markable id="markable_3" atrib="yes" span="word_10..word_24"> </markable> </markables> XML; Warning: Undefined variable $xml in /in/7rSXL on line 14 Deprecated: DOMDocument::loadXML(): Passing null to parameter #1 ($source) of type string is deprecated in /in/7rSXL on line 14 Fatal error: Uncaught ValueError: DOMDocument::loadXML(): Argument #1 ($source) must not be empty in /in/7rSXL:14 Stack trace: #0 /in/7rSXL(14): DOMDocument->loadXML('') #1 {main} thrown in /in/7rSXL on line 14
Process exited with code 255.
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30
$xml = <<<XML <?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE markables SYSTEM "markables.dtd"> <markables> <markable id="markable_1" atrib="yes" span="word_1..word_4"> </markable> <markable id="markable_2" atrib="no" span="word_6..word_7"> </markable> <markable id="markable_3" atrib="yes" span="word_10..word_24"> </markable> </markables> XML; Warning: Undefined variable $xml in /in/7rSXL on line 14 Fatal error: Uncaught ValueError: DOMDocument::loadXML(): Argument #1 ($source) must not be empty in /in/7rSXL:14 Stack trace: #0 /in/7rSXL(14): DOMDocument->loadXML('') #1 {main} thrown in /in/7rSXL on line 14
Process exited with code 255.
Output for 8.0.13
Parse error: syntax error, unexpected identifier "version" in /in/7rSXL on line 2
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 7.3.32 - 7.3.33, 7.4.33
Parse error: syntax error, unexpected 'version' (T_STRING) in /in/7rSXL on line 2
Process exited with code 255.
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.32
$xml = <<<XML <?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE markables SYSTEM "markables.dtd"> <markables> <markable id="markable_1" atrib="yes" span="word_1..word_4"> </markable> <markable id="markable_2" atrib="no" span="word_6..word_7"> </markable> <markable id="markable_3" atrib="yes" span="word_10..word_24"> </markable> </markables> XML; Notice: Undefined variable: xml in /in/7rSXL on line 14 Warning: DOMDocument::loadXML(): Empty string supplied as input in /in/7rSXL on line 14 <?xml version="1.0"?>
Output for 5.0.0 - 5.0.3
$xml = <<<XML <?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE markables SYSTEM "markables.dtd"> <markables> <markable id="markable_1" atrib="yes" span="word_1..word_4"> </markable> <markable id="markable_2" atrib="no" span="word_6..word_7"> </markable> <markable id="markable_3" atrib="yes" span="word_10..word_24"> </markable> </markables> XML; Notice: Undefined variable: xml in /in/7rSXL on line 14 Warning: DOMDocument::loadXML(): Empty string supplied as input in /in/7rSXL on line 14 <?xml version="1.0"?>
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
$xml = <<<XML <?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE markables SYSTEM "markables.dtd"> <markables> <markable id="markable_1" atrib="yes" span="word_1..word_4"> </markable> <markable id="markable_2" atrib="no" span="word_6..word_7"> </markable> <markable id="markable_3" atrib="yes" span="word_10..word_24"> </markable> </markables> XML; Fatal error: Cannot instantiate non-existent class: domdocument in /in/7rSXL on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1
$xml = <<<XML <?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE markables SYSTEM "markables.dtd"> <markables> <markable id="markable_1" atrib="yes" span="word_1..word_4"> </markable> <markable id="markable_2" atrib="no" span="word_6..word_7"> </markable> <markable id="markable_3" atrib="yes" span="word_10..word_24"> </markable> </markables> XML; Fatal error: Cannot instantiate non-existent class: domdocument in /in/7rSXL on line 13

preferences:
284.69 ms | 402 KiB | 462 Q