note 75699 deleted from function.str-ireplace by danbrown
| From: | danbrown@php.net | Date: | Mon, 18 May 2009 14:54:02 +0000 |
| Subject: | note 75699 deleted from function.str-ireplace by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155683@lists.php.net to get a copy of this message | ||
Note Submitter: lev at taintedthoughts dot com
----
There appears to be a "bug" with this function in at least version 5.2.1.
If you attempt to use the function while replacing special characters, such as new lines, it will
cause your entire scripts to fail. It resulted in my browser (Firefox 2) trying to download the file
instead of parsing it.
Here is example code which will cause problems:
<?php
$sometext = "this is some text\n";
$sometext .= "that has a new line in it";
echo break_lines($sometext);
function break_lines ($text)
{
return str_ireplace("\n", "<br/>", $text);
}
?>
However, if you simply get rid of the "i" and use the normal str_replace, the page will
load just fine.
I have also tried the same code on 5.2.3 and this version does NOT have the same problem, so it does
appear to be an issue that was resolved with the newest builds of php.
I don't think it was a result of my personal environment, but I am running Debian-Sarge, Apache
2 and PHP 5.2.1/5.2.3.