This script crashes PHP 5.2.1 everywhere. Command-line and web server (module and CGI modes). IMO, there's a bug somewhere in str_ireplace(). But it could be also more fundamental with how Zend treats variables. All that showing data around assigning a variable to itself.
I can reproduce it. Seems to be off-by-one here:
Z_STRVAL_P(result) = target = safe_emalloc(char_count, to_len, len);
introduced by this patch:
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.36&r2=1.445.2.14.2.37
If I replace len with len+1, it seems to be OK.
--
Stanislav Malyshev, Zend Products Engineer
stas@zend.com http://www.zend.com/