我正在编写一个邮件模板系统。用户应该能够在那里使用标记,它们将被实际数据替换。问题在于,我替换标记的函数工作得很好,但我需要对该函数进行递归调用,它只会运行一次,这就是我想出的:
public function replace_placeholders($content, $recipient, $settings, $interface, $recommendation, $format, $recursion = false) {
$content = $this->replace_ph('briefanrede' , $recipient['id'] , $content);
$content = $this->replace_ph('anrede' , $recipient['title'] , $content);
$content = $this->replace_ph('email' , $recipient['email'] , $content);
$content = $this->replace_ph('kundennummer' , $recipient['kdnumber'] , $content);
$content = $this->replace_ph('briefanrede' , $recipient['briefanrede'] , $content);
if($recipient['title'] == $settings['anrede_w'] || $recipient['title'] == $settings['anrede_m']) {
$content = $this->replace_ph('vorname' , $recipient['forename'] , $content);
$content = $this->replace_ph('nachname' , $recipient['surename'] , $content);
} else {
$content = $this->replace_ph('vorname' , "" , $content, true);
$content = $this->replace_ph('nachname' , "" , $content, true);
}
$content = $this->replace_salutation($recipient, $settings, $content);
//Recommendation
if($this->need_replacement($content, 'weiterempfehlung') === false && $recursion === false) {
if($recommendation['own_page'] == 1) {
$baseurl = $recommendation['location'];
} else {
$baseurl = $recommendation['link'];
}
$pattern = ($format == "html") ? '<a href="%s">%s</a>' : '%s';
$url = $this->replace_placeholders($baseurl, $recipient, $settings, $interface, $recommendation, true);
$content = $this->replace_ph('weiterempfehlung' , (($format == "html") ? sprintf($pattern, $url, $settings['text_weiterempfehlung']): sprinf($pattern, $url)), $content);
}
return $content;
}
此行中的递归调用
$url = $this->replace_placeholders($baseurl, $recipient, $settings, $interface, $recommendation, true);
导致 500 内部服务器错误。我不知道为什么,因为我认为我将递归限制为运行一次。你能帮我吗?
对不起,我的英语不好,我努力写出清晰的句子。
//编辑:
阿帕奇日志:
[Wed May 30 15:31:56 2012] [warn] [client xx.xxx.xx.xxx] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Wed May 30 15:31:56 2012] [warn] [client xx.xxx.xx.xxx] (104)Connection reset by peer: mod_fcgid: ap_pass_brigade failed in handle_request_ipc function
[Wed May 30 15:31:56 2012] [error] [client xx.xxx.xx.xxx] File does not exist: /var/www/web80/html/web80-newsletter/favicon.ico
[Wed May 30 15:31:58 2012] [error] mod_fcgid: process /var/www/php-fcgi/web80.php53/php-fcgi(21975) exit(communication error), get unexpected signal 11
php 错误日志为空。