Hi all,

I have found a problem using the str_replace() function in PHP5. Over this past weekend we switched our production server to php5.0.0 running on apache 1.3.31 on SUSE9.1. Our development environment is identical. I have an application that runs a series of str_replace calls to drop in some document title and link information into an html string before sending it to the browser.

Code example:
$html_string[0] = "<li><a href=\"read_docs.php?file=@@FISCAL_YEAR@@/@@month@@/393_@@TYPE@@.pdf&type=pdf&action=read\">GEP &amp; HIP Balances (GLC393)</a></li> ";


$html_output_1 .= $html_string[0];

$output = str_replace("@@FISCAL_YEAR@@", $this_year, $html_output_1 );

(I call it three times to do the replacements in the string).

This basically produces a list of documents with links to there location from a database call.

On our development box this little application runs fine. In production where our server is getting around 1 million hits a day (but the processor is rarely above 1% usage) this function completely fails. The page just doesn't get shown. If I comment out the calls to str_replace the html goes over perfectly with the @@TOKEN@@ instead of the necessary information. If I change the str_replace to say YEAR or FISCAL etc it makes no difference.

I dropped the production server to php 4.3.8 and the str_replace() function works exactly as expected and there are no problems loading the page. Bump back to php5.0.0 and it coughs again.

Has anyone else seen anything like this or does anyone have an explanation? I can recode the series of str_replace calls but now I'm somewhat worried that other solutions will also fail.

It seems to me like there's maybe a load tolerance bug in php5 when running str_replace() since I can't see this on our development box nor in 4.3.8.

The only difference in the functions between php4 and 5 is the addition of the count option, could that be the issue?

Any help or comments would be greatly appreciated.

Thanks

Jon Bertsch

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to