Jason Barnett wrote:
Jochem Maas wrote:
...
A better example code would be:
$string =
'period.backslash\\plus+star*question?lbracket[rbracket]carat^lparen(rparen)dollar$';
echo "<PRE>", quotemeta($string), "</PRE>";
Interesting aside... with the test string above, I noticed that
backslash\\ only resolved to two backslashes. I thought there would be
thats correct...
echo "\\"; // shows one backslash
I should have been clearer:
echo "\\"; // shows one backslash
echo '\\'; // shows one backslash
the backslash is a metachar in both single and double quoted
strings so regardless of the quotes used in order to write a
literal backslash in a string you must 'backslash' it.
you still not with me?:
echo '\'; // does this parse?
so the output of metaquote() is correct.
Well in the example above it was a single quote, not a double quote.
But either way... I would have thought there would be a 1:1 relationship
in the quotemeta translation (either quote all of them, or assume they
are all quoted already).
it quotes them all AFAIT.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php