Re: quotemeta() question...
| From: | Jochem Maas | Date: | Fri, 11 Feb 2005 21:36:02 +0000 |
| Subject: | Re: quotemeta() question... | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-208564@lists.php.net to get a copy of this message | ||
Jason Barnett wrote:
Richard Lynch wrote:thats correct... echo "\\"; // shows one backslashSteve Kaufman wrote:Interesting aside... with the test string above, I noticed that backslash\\ only resolved to two backslashes. I thought there would beWhy doesYou usually would use quotemeta on data coming from the database, or the user, or externally, or, errr, basically things you haven't typed in to PHP, that you need to pass into Regular Expressions. In those cases, you've already got the $ (and other characters) successfully embedded in the string, but you want to escape them for whatever reason. A better example code would be: $string = 'period.backslash\\plus+star*question?lbracket[rbracket]carat^lparen(rparen)dollar$'; echo "<PRE>", quotemeta($string), "</PRE>";quotemeta("pat:1$WRW")returnpat:1instead ofpat:1\$WRWWhat am I misunderstanding about quotemeta function?
4. It seems that quotemeta will resolve \ and \\ to \\, \\\ and \\\\ resolve to \\\\, etc. -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-general&w=2 STFM | http://www.php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins