Reply to Re: [PHP] quotemeta() question...

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация