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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平乐县| 宾川县| 丁青县| 宾阳县| 镇康县| 江陵县| 宣威市| 启东市| 鸡西市| 玉屏| 塔城市| 惠安县| 高青县| 阜宁县| 特克斯县| 临桂县| 和政县| 南丹县| 曲水县| 龙南县| 汨罗市| 咸阳市| 昌图县| 涟源市| 沁水县| 永春县| 淮滨县| 罗山县| 安国市| 上蔡县| 泰顺县| 汾西县| 金坛市| 汝阳县| 禄丰县| 高密市| 密山市| 威远县| 神木县| 和静县| 怀集县|