Discuz教程网

php Smarty模板生成html文档的方法

[复制链接]
authicon dly 发表于 2011-3-5 08:08:14 | 显示全部楼层 |阅读模式
下面直接发代码
代码如下:

  1. <?php
  2. /*
  3. file:config_smarty.php
  4. done:配置Smarty
  5. author:www.5dkx.com
  6. date:2009-12-21
  7. */
  8. include_once("../libs/smarty.class.php");
  9. class MySmarty extends Smarty{
  10. function __construct()
  11. {
  12. $this->Smarty();
  13. $this->config_dir = "../config";
  14. $this->cache_dir = "../cache";
  15. $this->template_dir = "../template";
  16. $this->compile_dir = "../template_c";
  17. $this->cache = false;
  18. }
  19. }
  20. $smart = new MySmarty();
  21. $smart->assign("title","标题");
  22. $smart->assign("content","内容");
  23. $smart->display('article.tpl');
  24. $output = $smart->fetch('article.tpl');
  25. $Path = "../html/1.html";
  26. $fp = fopen($Path,"w");
  27. fwrite($fp,$output);
  28. fclose($fp);
  29. ?>
复制代码






上一篇:比较不错的js退弹窗口代码,测试可以突破ie7
下一篇:CSS的真正匹配原理,让CSS更简洁、高效
authicon kurt226 发表于 2011-5-10 00:59:58 | 显示全部楼层
不错不错,我喜欢
authicon №小乖 发表于 2011-5-11 06:59:55 | 显示全部楼层
好东东下下来看看
authicon TRACYFLYING 发表于 2011-5-12 16:59:47 | 显示全部楼层
这个要顶起来啊
authicon soul2511 发表于 2011-5-13 06:59:39 | 显示全部楼层
真的有意思!
authicon ningbear 发表于 2011-5-14 20:59:59 | 显示全部楼层
喜欢喜欢喜欢
authicon NicoleOnly 发表于 2011-5-14 23:59:50 | 显示全部楼层
好东西要顶的。
authicon Pianissimo 发表于 2011-5-16 01:59:49 | 显示全部楼层
支持楼主,顶一下
authicon 皆无 发表于 2011-5-20 22:59:44 | 显示全部楼层
好东西,要下来看看
authicon lanyuqing 发表于 2011-5-23 15:59:35 | 显示全部楼层
不错不错,我喜欢
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 14:08

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表