Posted by Jochem Maas on 02/12/05 01:14
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.
>
>>
[Back to original message]
|