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" atrib="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_IdatziDok->query('//PersonList/Person/Name') AS $Idaztekoa) { $IdaztekoaID = $Idaztekoa->getAttribute('id'); $IdaztekoaAtrib = $Idaztekoa->getAttribute('atrib'); if($IdaztekoaAtrib != "yes") { $Idazteko->Attribute('atrib','yes'); } } $doc->formatOutput = true; echo $doc->saveXML();
Output for 7.0.5 - 7.1.0
Notice: Undefined variable: xPath_IdatziDok in /in/kLh16 on line 32 Fatal error: Uncaught Error: Call to a member function query() on null in /in/kLh16:32 Stack trace: #0 {main} thrown in /in/kLh16 on line 32
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: xPath_IdatziDok in /in/kLh16 on line 32 Fatal error: Uncaught Error: Call to a member function query() on unknown in /in/kLh16:32 Stack trace: #0 {main} thrown in /in/kLh16 on line 32
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined variable: xPath_IdatziDok in /in/kLh16 on line 32 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function query() on a non-object (null)' in /in/kLh16:32 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.28
Notice: Undefined variable: xPath_IdatziDok in /in/kLh16 on line 32 Fatal error: Call to a member function query() on null in /in/kLh16 on line 32
Process exited with code 255.
Output for 5.5.0 - 5.5.35
Notice: Undefined variable: xPath_IdatziDok in /in/kLh16 on line 32 Fatal error: Call to a member function query() on a non-object in /in/kLh16 on line 32
Process exited with code 255.
Output for 5.2.3 - 5.4.45
Fatal error: Call to a member function query() on a non-object in /in/kLh16 on line 32
Process exited with code 255.
Output for 5.0.0 - 5.1.1, 5.1.3 - 5.2.2
<br /> <b>Fatal error</b>: Call to a member function query() on a non-object in <b>/in/kLh16</b> on line <b>32</b><br />
Process exited with code 255.
Output for 5.1.2
<br /> <b>Fatal error</b>: Call to a member function query() on a non-object in <b>/in/kLh16</b> on line <b>33</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.9
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: domdocument in <b>/in/kLh16</b> on line <b>28</b><br />
Process exited with code 255.
Output for 4.4.2
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: domdocument in <b>/in/kLh16</b> on line <b>29</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: domdocument in <b>/in/kLh16</b> on line <b>28</b><br />