3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $content = <<<XML <?xml version="1.0" encoding="ISO-8859-1"?> <PersonList> <Header> </Header> <Person> <Name id="35" nume="LOL">Sonu Kapoor</Name> <Age>24</Age> <Gender>M</Gender> <PostalCode>54879</PostalCode> </Person> <Person> <Name>Jasmin</Name> <Age>28</Age> <Gender>M</Gender> <PostalCode>78745</PostalCode> </Person> <Person> <Name>Josef</Name> <Age>232</Age> <Gender>F</Gender> <PostalCode>53454</PostalCode> </Person> </PersonList> XML; $doc = new DOMDocument(); $doc->loadXML($content); $xp = new DOMXPath($doc); foreach ($xPath->query('//PersonList/Person/Name') AS $Name) { $ID = $Name->getAttribute('id'); $Atrib = $Name->getAttribute('nume'); if($Atrib != "") { $Name->setAttribute('nume','Nuevo'); } } $doc->formatOutput = true; echo $doc->saveXML();
Output for 7.0.5 - 7.1.0
Notice: Undefined variable: xPath in /in/qaFKW on line 32 Fatal error: Uncaught Error: Call to a member function query() on null in /in/qaFKW:32 Stack trace: #0 {main} thrown in /in/qaFKW on line 32
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: xPath in /in/qaFKW on line 32 Fatal error: Uncaught Error: Call to a member function query() on unknown in /in/qaFKW:32 Stack trace: #0 {main} thrown in /in/qaFKW on line 32
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Notice: Undefined variable: xPath in /in/qaFKW on line 32 Fatal error: Call to a member function query() on null in /in/qaFKW on line 32
Process exited with code 255.
Output for 5.0.4 - 5.1.1, 5.1.3 - 5.5.35
Notice: Undefined variable: xPath in /in/qaFKW on line 32 Fatal error: Call to a member function query() on a non-object in /in/qaFKW on line 32
Process exited with code 255.
Output for 5.1.2
Notice: Undefined variable: xPath in /in/qaFKW on line 33 Fatal error: Call to a member function query() on a non-object in /in/qaFKW on line 33
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: xPath in /in/qaFKW on line 32 Fatal error: Call to a member function query() on a non-object in /in/qaFKW on line 32
Process exited with code 255.
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/qaFKW on line 28
Process exited with code 255.
Output for 4.4.2
Fatal error: Cannot instantiate non-existent class: domdocument in /in/qaFKW on line 29
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/qaFKW on line 28