国产探花免费观看_亚洲丰满少妇自慰呻吟_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程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 中阳县| 宿州市| 澄江县| 岳阳县| 连江县| 北宁市| 汝阳县| 米脂县| 凤台县| 比如县| 维西| 奉节县| 手游| 湘潭市| 桐梓县| 大英县| 永川市| 桃源县| 顺义区| 清水县| 青神县| 泰安市| 阿拉善盟| 灵丘县| 达尔| 淅川县| 巴林左旗| 舟山市| 忻城县| 剑川县| 板桥市| 武乡县| 客服| 元阳县| 八宿县| 凤台县| 江城| 广安市| 喜德县| 关岭| 德兴市|