PHP 8.5.0 Alpha 4 available for testing

Voting

: seven plus two?
(Example: nine)

The Note You're Voting On

Niklas
16 years ago
For XPath escaping use the following method (of course it could be more efficient).
<?php
public function xpathescape($string)
{
$result = 'concat(';

for(
$i=0, $j=strlen($string); $i<$j; ++$i)
{
if(
$i > 0)
$result .= ",";

if(
$string[$i] == '\'')
$result .= "\"".$string[$i]."\"";
else
$result .= '\''.$string[$i].'\'';
}

$result .= ')';

return
$result;
}
?>

Use it this way:
<php
$xpath->query('//example[sub='.xpathescape($acomplexstring).']');

?>

<< Back to user notes page

To Top