note 75699 added to function.str-ireplace

From: Date: Tue, 12 Jun 2007 15:03:46 +0000
Subject: note 75699 added to function.str-ireplace
Groups: php.notes 
Request: Send a blank email to php-notes+get-127418@lists.php.net to get a copy of this message
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. ---- Server IP: 129.16.214.50 Probable Submitter: 83.227.147.212 ---- Manual Page -- http://www.php.net/manual/en/function.str-ireplace.php Edit -- https://master.php.net/note/edit/75699 Del: integrated -- https://master.php.net/note/delete/75699/integrated Del: useless -- https://master.php.net/note/delete/75699/useless Del: bad code -- https://master.php.net/note/delete/75699/bad+code Del: spam -- https://master.php.net/note/delete/75699/spam Del: non-english -- https://master.php.net/note/delete/75699/non-english Del: in docs -- https://master.php.net/note/delete/75699/in+docs Del: other reasons-- https://master.php.net/note/delete/75699 Reject -- https://master.php.net/note/reject/75699 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#127418) next »