note 70895 deleted from function.str-replace by philip
| From: | philip@php.net | Date: | Mon, 26 Feb 2007 07:17:48 +0000 |
| Subject: | note 70895 deleted from function.str-replace by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123888@lists.php.net to get a copy of this message | ||
Note Submitter: mcdaddy at godaddy dot com
----
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);
}