我的函数是
function template($file, $_str=array(), $isfile=true){
if($isfile){
$content = file_get_contents($file);
}else{
$content = $file;
}
foreach($_str as $key=>$st){
$content = str_replace("{".$key."}", $_str[$key], $content);
}
return $content;
}
我的例子
$file = "a.html"; //这个a.html中有 {a} 和 {b} ,
$tempArray = array("a"=>"张三", "b"=>"王五");
template($file, $tempArray);
运行勉强可以通过,但总提示我的函数template()有错,还指明是
foreach($_str as $key=>$st){
$content = str_replace("{".$key."}", $_str[$key], $content);
}
环节出错,我实在看不出哪里出错,请大家帮我看看????谢谢了,