Re: quotemeta() question...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux