我有两个文件,一共是PHP文件,一共是静态的HTML文件,如何将PHP中的变量值传到HTML文件中?
如PHP中有一个变量A=12345678,我要把A的值12345678传到html文件中并在html文件中显示出来!不是参数传递哦!!!就是像写文件一样!!!
如PHP中有一个变量A=12345678,我要把A的值12345678传到html文件中并在html文件中显示出来!不是参数传递哦!!!就是像写文件一样!!!
2、使用模板。
class templet{
private $source_file;
function get_file($filename){
$this->source_file = file_get_contents($filename);
}
function parse($tags,$vals){
if(!is_array($tags)){
return preg_replace("|{".$tags."}|",$vals,$this->source_file);
}else{
$an = count($tags);
for($i=0;$i<$an;$i++){
$tags[$i] = "|{".$tags[$i]."}|";
}
return preg_replace($tags,$vals,$this->source_file);
}
}
}
呵呵,当然smarty、phplib中的template.inc都不错!