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(translate(photographer,$searchKeyword) )]"); print_r($area);
based on kGJYk
Output for 5.4.41 - 7.2.0
Warning: SimpleXMLElement::xpath(): Invalid number of arguments in /in/juiKg on line 30 Warning: SimpleXMLElement::xpath(): xmlXPathEval: 3 object left on the stack in /in/juiKg on line 30
Output for 5.1.0 - 5.1.1, 5.1.3 - 5.4.40
Warning: SimpleXMLElement::xpath(): Invalid number of arguments in /in/juiKg on line 30 Warning: SimpleXMLElement::xpath(): Invalid number of arguments in /in/juiKg on line 30 Warning: SimpleXMLElement::xpath(): xmlXPathEval: 3 object left on the stack in /in/juiKg on line 30
Output for 5.1.2
Warning: SimpleXMLElement::xpath(): Invalid number of arguments in /in/juiKg on line 31 Warning: SimpleXMLElement::xpath(): Invalid number of arguments in /in/juiKg on line 31 Warning: SimpleXMLElement::xpath(): xmlXPathEval: 3 object left on the stack in /in/juiKg on line 31
Output for 5.0.0 - 5.0.5
Warning: Invalid number of arguments in /in/juiKg on line 30 Warning: Invalid number of arguments in /in/juiKg on line 30 Warning: xmlXPathEval: 3 object left on the stack in /in/juiKg on line 30
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/juiKg on line 28
Process exited with code 255.
Output for 4.4.2
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/juiKg 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/juiKg on line 28