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

首頁 > 開發(fā) > PHP > 正文

php簡單smarty入門程序?qū)嵗?/h1>
2024-05-04 23:36:08
字體:
供稿:網(wǎng)友

這篇文章主要介紹了php簡單smarty入門程序,實(shí)例分析了smarty模板的配置與使用技巧,需要的朋友可以參考下

本文實(shí)例講述了php簡單smarty入門程序。分享給大家供大家參考。具體如下:

首先要有3個(gè)文件夾configs、templates、templates_c,在configs文件夾中有一個(gè)配置文件:test.conf,代碼:

 

 
  1. title = Welcome to Smarty! 
  2. cutoff_size = 40 
  3. [setup] 
  4. bold = true 

templates中有模板文件:test.htm:

 

 
  1. <html>  
  2. <head>  
  3. <title>Smarty Test</title>  
  4. </head>  
  5. <body>  
  6. <H1>Hello, {$Name}</H1>  
  7. </body>  
  8. </html>  

php文件代碼:

 

 
  1. <?php  
  2. require 'libs/Smarty.class.php'//包含Smarty類庫文件  
  3. $smarty = new Smarty; //創(chuàng)建一個(gè)新的Smarty對(duì)象  
  4. $smarty->assign("Name","Simon"); //對(duì)模版中的變量賦值  
  5. $smarty->display('test.htm'); //顯示頁面  
  6. ?> 

運(yùn)行后顯示的頁面代碼:

 

 
  1. <html>  
  2. <head>  
  3. <title>Smarty Test</title>  
  4. </head>  
  5. <body>  
  6. <H1>Hello, Simon</H1>  
  7. </body>  
  8. </html>  

運(yùn)行之后,還在templates_c文件夾中生成一個(gè)php文件:

 

 
  1. <?php 
  2. /* Smarty version 2.6.22, created on 2009-03-19 13:20:00  
  3. compiled from test.htm */ 
  4. ?>  
  5. <html>  
  6. <head>  
  7. <title>Smarty Test</title>  
  8. </head>  
  9. <body>  
  10. <H1>Hello, <?php echo $this->_tpl_vars['Name']; ?>  
  11. </H1>  
  12. </body>  
  13. </html>  

這個(gè)文件就是瀏覽所顯示出來的效果。

希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

主站蜘蛛池模板: 彰化县| 道真| 合水县| 尚志市| 乌兰县| 泰宁县| 杭锦旗| 合肥市| 伽师县| 安多县| 双桥区| 泰宁县| 兴文县| 灵璧县| 北流市| 芮城县| 潼关县| 平度市| 财经| 巍山| 农安县| 正宁县| 佛坪县| 新竹县| 斗六市| 大新县| 哈巴河县| 永年县| 翼城县| 静安区| 加查县| 灵石县| 满城县| 彭州市| 贵溪市| 柳州市| 济宁市| 潼南县| 澄迈县| 明水县| 汾阳市|