$data = {include "header.tpl"}{include "footer.tpl"};
private function get_tpl_includes($data){
$this->includes = preg_match_all('/{include \"[^}]\"*}/', $data, $this->includes);
foreach($this->includes as $include){
$tpl_file = $this->dir . str_replace($this->dir, "", $include[0]);
$html_include = file_get_contents($tpl_file) or die("tp3"); //Get the content of the included html
$pattern = '{include "' . $tpl_file . '"}'; //Create a pattern to replace in the html
$this->html = str_ireplace($pattern, "", $this->html); //Replace the file include pattern with html
}
}
这段代码是否正确,因为尽管页脚和头文件不为空,但它没有产生任何输出。