note 124656 added to domxpath.evaluate
| From: | danny at webdevelopers dot eu | Date: | Tue, 28 Jan 2020 11:36:01 +0000 |
| Subject: | note 124656 added to domxpath.evaluate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-213969@lists.php.net to get a copy of this message | ||
The only way how to distinguish FALSE returned value from syntax error FALSE is to re-run the XPath
expression wrapped in string() function. If must return empty string. If it returns FALSE again then
it is an error.
<?php
$ret=$this->xp->evaluate($eval, $context);
// Error detection: DOMXPath::evaluate() returns FALSE on error
// so does DOMXPath::evaluate("boolean(/nothing)")
// @workaround webdevelopers.eu
if ($ret === false && $this->xp->evaluate("string($eval)", $context)
=== false) {
throw new Exception("Invalid XPath expression ".json_encode($eval), 3491);
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 103.51.167.36 (proxied: 85.70.213.104)
----
Manual Page -- http://php.net/manual/en/domxpath.evaluate.php
Edit -- https://master.php.net/note/edit/124656
Del: integrated -- https://master.php.net/note/delete/124656/integrated
Del: useless -- https://master.php.net/note/delete/124656/useless
Del: bad code -- https://master.php.net/note/delete/124656/bad+code
Del: spam -- https://master.php.net/note/delete/124656/spam
Del: non-english -- https://master.php.net/note/delete/124656/non-english
Del: in docs -- https://master.php.net/note/delete/124656/in+docs
Del: other reasons-- https://master.php.net/note/delete/124656
Reject -- https://master.php.net/note/reject/124656
Search -- https://master.php.net/manage/user-notes.php