代码如下 | 复制代码 |
class create_html { private $template; //模版 private $file_name; //文件名 private $array; //数据数组 function __construct($file_name, $template, $array) { //构造类 $this->template = $this->read_file($template, "r"); //读取模板文件 $this->file_name = $file_name; $this->array = $array; //数据数据 $this->html(); //生成html } function html() { //生成html while (ereg ("{([0-9]+)}", $this->template, $regs)) { //循环模版中所能的{1}….. $num = $regs[1]; //得到1、2、3序列 $this->template = ereg_replace("{".$num."}", $this->array[$num], $this->template); //把数据替换成html内容 $this->write_file($this->file_name, $this->template, "w+"); //生成HTML文件 } } function read_file($file_url, $method = "r") { //读取文件 $fp = @fopen($file_url, $method); //打开文件 $file_data = fread($fp, filesize($file_url)); //读取文件信息 return $file_data; } function write_file($file_url, $data, $method) { //写入文件 $fp = @fopen($file_url, $method); //打开文件 @flock($fp, LOCK_EX); //锁定文件 $file_data = fwrite($fp, $data); //写入文件 fclose($fp); //关闭文件 return $file_data; } } #例子———————- #读取邮件回复模版———————————————————————————- $title = "标题"; $navigation = "浏览器"; $happy_origin = "作者"; $name = "test2.htm"; $template = "default_tmp.php"; //模版中用{1}{2}来替换 $daytype = array(1 => $title, 2 => $navigation, 3 => $happy_origin); $htm = new Restore_email($template, $daytype); echo $htm->pint(); ?> |
敢达决战官方正版 安卓版v6.7.9
下载敢达决战 安卓版v6.7.9
下载像素火影骨架佐助 (Perseverance Fire Shadow)手机版v1.16
下载要塞英雄 安卓版v33.20.0-39082670-Android
下载梦想城镇vivo最新版本 安卓版v12.0.1
梦想城镇vivo版是这款卡通风模拟经营类手游的渠道服版本,玩
怦然心动的瞬间 安卓版v1.0
怦然心动的瞬间是一款真人向的恋爱互动游戏,在游戏中玩家将扮演
曼尼汉堡店游戏 安卓版v1.0.3
曼尼汉堡店是一款非常好玩的精品恐怖类型冒险游戏,在这款游戏中
现代总统模拟器去广告版 安卓版v1.0.46
现代总统模拟器是一款休闲养成类游戏,可能对于不少的玩家来说都
现代总统模拟器付费完整版 安卓版v1.0.46
现代总统模拟器高级版在商店是需要付费的,相对于普通版本,高级