Discuz教程网

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

[复制链接]
authicon dly 发表于 2011-8-28 10:13:28 | 显示全部楼层 |阅读模式
下面直接发代码
代码如下:
  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. ?>
复制代码




上一篇:在smarty模板中使用PHP函数的方法
下一篇:Blitz templates 最快的PHP模板引擎
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 10:47

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

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