3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = <<<XML <?xml version="1.0" encoding="utf-8"?> <toflag> <flagarea formulaid="1" eventid="100" sessionid="421" sectionid="180001" floorid="180001" zoneid="180001" categoryid="180001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="207" sessionid="423" sectionid="180001" floorid="180001" zoneid="180001" categoryid="180001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="94" sessionid="117" sectionid="170001" floorid="0" zoneid="170001" categoryid="170001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="120" sessionid="155" sectionid="170001" floorid="0" zoneid="170001" categoryid="170001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> </toflag> XML; $dom = new DOMDocument; $dom->loadXML($xml); $dom->formatOutput = true; $xpath = new DOMXpath($dom); $query = '/toflag/flagarea[@formulaid="1" and @eventid="207" and @sessionid="423" and @sectionid="180001" and @floorid="180001" and @zoneid="180001" and @categoryid="180001"]/flagbloc[@priceid="4410026"]'; $result = $xpath->query($query); if ($result->length) { $flagBloc = $result->item(0); var_dump($flagBloc->nodeValue); $flagBloc->nodeValue = intval($flagBloc->nodeValue, 10) + 1; } echo $dom->saveXML();
Output for 5.0.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
string(1) "1" <?xml version="1.0" encoding="utf-8"?> <toflag> <flagarea formulaid="1" eventid="100" sessionid="421" sectionid="180001" floorid="180001" zoneid="180001" categoryid="180001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="207" sessionid="423" sectionid="180001" floorid="180001" zoneid="180001" categoryid="180001"> <flagbloc priceid="4410026">2</flagbloc> </flagarea> <flagarea formulaid="1" eventid="94" sessionid="117" sectionid="170001" floorid="0" zoneid="170001" categoryid="170001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="120" sessionid="155" sectionid="170001" floorid="0" zoneid="170001" categoryid="170001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> </toflag>
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/hoN1q on line 20
Process exited with code 255.
Output for 4.4.2
Fatal error: Cannot instantiate non-existent class: domdocument in /in/hoN1q on line 21
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/hoN1q on line 20