Re: quotemeta() question...
| From: | Jochem Maas | Date: | Fri, 11 Feb 2005 23:14:37 +0000 |
| Subject: | Re: quotemeta() question... | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-208575@lists.php.net to get a copy of this message | ||
Jason Barnett wrote:
Jochem Maas wrote: ...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.thats correct... echo "\\"; // shows one backslashA 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
it quotes them all AFAIT.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).