note 21483 deleted from function.preg-replace by sniper
| From: | sniper@php.net | Date: | Sun, 07 Sep 2003 22:07:11 +0000 |
| Subject: | note 21483 deleted from function.preg-replace by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-55709@lists.php.net to get a copy of this message | ||
Note Submitter: jeff@procata.com
----
This is just a reminder to be careful to use preg_quote() where appropriate on both the search
string AND the replacement string. Here is an example of an error caused by the failure to do so on
the replacement string:
$text = "xyz salary abc";
$search = "/salary/";
$replacement = "$1,000,000 dollars";
echo preg_replace($search, $replacement, $text); // BAD
I had a problem with this when a HTTP_POST_VARS value was included in a replacement pattern and the
user had entered a value with special characters.