3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <root> <area> <photographer_id>1</photographer_id> <photographer>John</photographer> <image>a</image> </area> <area> <photographer_id>1</photographer_id> <photographer>John</photographer> <image>b</image> </area> <area> <photographer_id>1</photographer_id> <photographer>John</photographer> <image>c</image> </area> <area> <photographer_id>2</photographer_id> <photographer>Fred</photographer> <image>a</image> </area> </root> XML; $sxe = new SimpleXMLElement($xml); $searchKeyword = "Fred"; $area = $sxe->xpath("//area[contains(photographer, {$searchKeyword} )]"); print_r($area);
based on 94cVi
Output for 5.0.0 - 7.2.0
Array ( [0] => SimpleXMLElement Object ( [photographer_id] => 1 [photographer] => John [image] => a ) [1] => SimpleXMLElement Object ( [photographer_id] => 1 [photographer] => John [image] => b ) [2] => SimpleXMLElement Object ( [photographer_id] => 1 [photographer] => John [image] => c ) [3] => SimpleXMLElement Object ( [photographer_id] => 2 [photographer] => Fred [image] => a ) )
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/v9peY on line 28
Process exited with code 255.
Output for 4.4.2
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/v9peY on line 29
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/v9peY on line 28