在languagebag.php中

<?php
ob_start();
include_once 'template/index.html'; //加载模板文件,并执行里面的php指令
$str = ob_get_contents();
ob_clean();

$zh_arr = array( //中文语言包
'name'        => '姓名',
'address'    => '地址',
'date'        => '日期'    
);
$en_arr = array( //英文语言包
'name'        => 'Name',
'address'    => 'Address',
'date'        => 'Date'
);

$lan_arr = $zh_arr; //选择语言包
foreach ($lan_arr as $key => $value){ //遍历语言包,替换变量
$str = str_replace('{$'.$key.'}',$value,$str);
}
echo $str; //输出页面内容
ob_flush(); //刷新缓冲区
?>

在tempalte/index.html中

<!doctype html>
<html>
    <body>
        {$name}
        {$address}
        {$date}
    </body>
    
</html>