国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

Smarty使用自定義資源的方法

2024-05-04 23:38:39
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了Smarty使用自定義資源的方法,實例分析了smarty自定義資源的定義與使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了Smarty使用自定義資源的方法。分享給大家供大家參考。具體如下:

 

  1. <?php 
  2. // put these function somewhere in your application 
  3. function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj
  4. // do database call here to fetch your template, 
  5. // populating $tpl_source 
  6. $sql = new SQL; 
  7. $sql->query("select tpl_source 
  8. from my_table 
  9. where tpl_name='$tpl_name'"); 
  10. if ($sql->num_rows) { 
  11. $tpl_source = $sql->record['tpl_source']; 
  12. return true; 
  13. else { 
  14. return false; 
  15. function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj
  16. // do database call here to populate $tpl_timestamp. 
  17. $sql = new SQL; 
  18. $sql->query("select tpl_timestamp 
  19. from my_table 
  20. where tpl_name='$tpl_name'"); 
  21. if ($sql->num_rows) { 
  22. $tpl_timestamp = $sql->record['tpl_timestamp']; 
  23. return true; 
  24. else { 
  25. return false; 
  26. function db_get_secure($tpl_name, &$smarty_obj
  27. // assume all templates are secure 
  28. return true; 
  29. function db_get_trusted($tpl_name, &$smarty_obj
  30. // not used for templates 
  31. // register the resource name "db" 
  32. $smarty->register_resource("db"array("db_get_template"
  33. "db_get_timestamp"
  34. "db_get_secure"
  35. "db_get_trusted")); 
  36. // using resource from php script 
  37. $smarty->display("db:index.tpl"); 
  38. ?> 

希望本文所述對大家基于smarty的php程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 雷州市| 类乌齐县| 南阳市| 庄河市| 九江县| 唐山市| 乡城县| 拜泉县| 望江县| 郸城县| 大悟县| 周宁县| 通榆县| 吉木萨尔县| 余庆县| 乐昌市| 汉川市| 宣城市| 昌吉市| 凭祥市| 临西县| 合江县| 星子县| 新邵县| 西乌珠穆沁旗| 高要市| 轮台县| 阿瓦提县| 嵊州市| 通河县| 建宁县| 房山区| 富源县| 梅州市| 辉县市| 花莲县| 马龙县| 防城港市| 和平县| 三明市| 绥芬河市|