# Infinite loop

- Thread: https://externals.io/message/8502
- Original archive: https://news-web.php.net/php.internals/8502
- Started by Joe Estock on 2004-03-13T13:28:49+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #8502 — Joe Estock — 2004-03-13T13:28:49+00:00

URL: https://externals.io/message/8502#8502

I know that this would most likely never be used, however someone 
brought this to my attention and I have verified it on PHP 4.3.4 on 
FreeBSD 5.2.1-RELEASE as well as PHP 4.3.4 on Windows XP.

---
while(str_replace(' ', '  ', '  f  dfd  34   dsf ')) {  }
---

This results in PHP obviously becoming stuck in an infinite loop. The 
semantecs of it make complete sense, str_replace will always return TRUE.

My question is this: Shouldn't there be some type of detection for this 
that would at least cause PHP to throw a warning?

Regards,

Joe Estock (guru)

---

## #8503 — Jan Lehnardt — 2004-03-13T13:39:36+00:00

URL: https://externals.io/message/8502#8503 · In reply to: #8502

Hi,

> My question is this: Shouldn't there be some
> type of detection for this that would at least
>  cause PHP to throw a warning?

while(1); or for(;;;); result in an infinite loop, too
and there are cases where it is intentional. PHP is not
there to check for programming mistakes. Also, see the
archives for more discussion on this.

Regards,
Jan (no-guru)
--
GPG Key: BB96 56B0
Q: Thank Jan? - A: http://geschenke.an.dasmoped.net/
