note 21483 added to function.preg-replace
| From: | jeff at procata dot com | Date: | Tue, 14 May 2002 20:49:57 +0000 |
| Subject: | note 21483 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30644@lists.php.net to get a copy of this message | ||
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.
--
http://www.php.net/manual/en/function.preg-replace.php
http://master.php.net/manage/user-notes.php?action=edit+21483
http://master.php.net/manage/user-notes.php?action=delete+21483
http://master.php.net/manage/user-notes.php?action=reject+21483