note 78201 added to function.str-replace

From: Date: Wed, 03 Oct 2007 02:31:10 +0000
Subject: note 78201 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-131017@lists.php.net to get a copy of this message
If your replace string results from an expression or a function, str_replace will evaluate/call it even if the search string is not found. function am_i_called () { echo "oh no, i am<br>"; return ""; } str_replace ("zzz", am_i_called (), "this string does not contain the search string"); str_replace ("zzz", $result = "rats!", "this string does not contain the search string"); echo "$result<br>"; // oh no, i am // rats! also it isn't re-evaluated for multiple replacements... echo str_replace ("zzz", $result = "r".$result, "zzz zzz zzz zzz zzz zzz zzz"); // rrats! rrats! rrats! rrats! rrats! rrats! rrats! ---- Server IP: 69.147.83.197 Probable Submitter: 189.138.39.106 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- https://master.php.net/note/edit/78201 Del: integrated -- https://master.php.net/note/delete/78201/integrated Del: useless -- https://master.php.net/note/delete/78201/useless Del: bad code -- https://master.php.net/note/delete/78201/bad+code Del: spam -- https://master.php.net/note/delete/78201/spam Del: non-english -- https://master.php.net/note/delete/78201/non-english Del: in docs -- https://master.php.net/note/delete/78201/in+docs Del: other reasons-- https://master.php.net/note/delete/78201 Reject -- https://master.php.net/note/reject/78201 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131017) next »