note 70895 added to function.str-replace

From: Date: Fri, 03 Nov 2006 10:23:39 +0000
Subject: note 70895 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-119331@lists.php.net to get a copy of this message
Take the following code: $x = "Test@DATA@Test"; echo str_replace("@DATA@", "Test@DATA@Test", $x); At first glance, one might think this could cause an infinite loop (continuous expansion). Thankfully this only expands to: TestTest@DATA@TestTest Of course, the following WILL cause an infinite loop (and possibly run the system out of memory): $x = "Test@DATA@Test"; $Count = 1; while ($Count) { $x = str_replace("@DATA@", "Test@DATA@Test", $x, $Count); } ---- Server IP: 216.194.113.175 Probable Submitter: 67.172.82.185 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- https://master.php.net/note/edit/70895 Del: integrated -- https://master.php.net/note/delete/70895/integrated Del: useless -- https://master.php.net/note/delete/70895/useless Del: bad code -- https://master.php.net/note/delete/70895/bad+code Del: spam -- https://master.php.net/note/delete/70895/spam Del: non-english -- https://master.php.net/note/delete/70895/non-english Del: in docs -- https://master.php.net/note/delete/70895/in+docs Del: other reasons-- https://master.php.net/note/delete/70895 Reject -- https://master.php.net/note/reject/70895 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119331) next »