note 108777 modified in function.str-replace by danbrown
| From: | danbrown@php.net | Date: | Thu, 24 May 2012 17:29:15 +0000 |
| Subject: | note 108777 modified in function.str-replace by danbrown | ||
| References: | 1 | Groups: | php.notes php.notes |
| Request: | Send a blank email to php-notes+get-188200@lists.php.net to get a copy of this message | ||
I noticed that if you use mysql_real_escape_string() before performing str_replace, it won't
work. This may be dependent on the string being replaced. Specifically, the following, won't
work: <?php $formattedPost =
mysql_real_escape_string($formattedPost); $formattedPost =
str_replace("\\r\\n", "<br>",
$comment); ?> Do this
instead: <?php $formattedPost =
str_replace("\\r\\n", "<br>",
$comment); $formattedPost =
mysql_real_escape_string($formattedPost); ?>
--was--
I noticed that if you use mysql_real_escape_string() before performing str_replace, it won't
work. This may be dependent on the string being replaced. Specifically, the following, won't
work:
$formattedPost = mysql_real_escape_string($formattedPost);
$formattedPost = str_replace("\r\n", "<br>", $comment);
Do this instead:
$formattedPost = str_replace("\r\n", "<br>", $comment);
$formattedPost = mysql_real_escape_string($formattedPost);
http://php.net/manual/en/function.str-replace.php