500 server error with recursion?!
Posted: Thu Jul 20, 2006 8:30 pm
Pimptastic | Please use
this function should simply change a string formatted as "[ttl[...]]" to "<h3>...</h3>" for all instances in a long string of text (thus the recursive algorithm)
this algorithm works perfect if i take out the recursive call.
can anyone help on this one?
thanks.
Al.
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
can anyone perhaps enlighten me as to why my apache server is throwing a 500 level server error with this code.
the error is specifically logged as "Premature end of script headers: php-cgi.exe"Code: Select all
function replaceTitles($str) {
$tag_open = "[ttl[";
$tag_close = "]]";
$i = strpos($str, $tag_open);
if ($i >= 0) {
// Replace the start tag
$str = trim(substr($str, 0, $i))."<h3>".trim(substr($str, $i+strlen($tag_open)));
// Replace the end tag
$i = strpos($str, $tag_close, $i);
$str = trim(substr($str, 0, $i))."</h3>".trim(substr($str, $i+strlen($tag_close)));
// ******************************
// Recursively check for more title tags
// ******************************
return replaceTitles($str);
} else
return $str;
}
$text = "[ttl[bigTitle! ]]Hello this is my text [ttl[WORD!]]. i love my text[when it's in brackets]";
echo replaceTitles($text);this algorithm works perfect if i take out the recursive call.
can anyone help on this one?
thanks.
Al.
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]