메일 템플릿 시스템을 프로그래밍하고있었습니다. 사용자는 거기에서 마커를 사용할 수 있어야하며 실제 데이터로 대체됩니다. 문제의 표준시는 마커를 대체 할 내 기능은 잘 작동하지만, 내가 해낸 내가 한 번만 실행됩니다 그 함수의 recursiv 호출을 할 필요가 있고, 이것이다 :PHP 재귀 호출로 인해 서버 간 오류가 발생했습니다.
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;
}
recursiv 이 행의 전화
$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는 오류 로그가 비어 있습니다.
더 자세한 오류 메시지는 서버 로그를 참조하십시오. –
IF 문이 매번 true를 반환하는 것처럼 보이기 때문에'if ($ this-> need_replacement ($ content, 'weiterempfehlung') === false && $ recursion === false) {' 스크립트 실행 시간 초과 또는 메모리 부족으로 PHP가 종료 될 때까지 스크립트가 중단되지 않습니다. – Gavin
if case에서 볼 수 있듯이 재귀 호출이 $ param $ recursion === true로 완료되면 if 문에서 루프가 가능하지 않아야합니다. –