首页 > 其他 > 详细

生成用户界面

时间:2018-05-21 13:38:45      阅读:157      评论:0      收藏:0      [点我收藏+]

<?php
class Mytpl{
 //输出页面
 protected $tpl_val = array();
 function display($url){
  $content = file_get_contents($url); //获取模板资源
  foreach ($this->tpl_val as $k => $v) {//翻译
   $content = str_repeat(‘{$‘.$k.‘}‘, $v,$content);
  $complie_url = "文件夹名/".md5($url).".php";//设置临时文件路径    md5()加密
  file_put_contents($complie_url, $content);//输出资源
  include_once $complie_url;
 }
 function assign($k,$v){//将许可的变量放入数组
   $this->tpl_val[$k] = $v;
 }
}
$tpl = new Mytpl();
$tpl->assign(‘a‘,‘哈哈‘);
$tpl->display(‘index2.html‘);

 

 

 

 

----------------------------------index2.html------------------------------

<!DOCTYPE HTML>
<html >
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 </head>
 <body>
 你好{$a}
 </body>
</html>

生成用户界面

原文:https://www.cnblogs.com/index0629/p/9066430.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!