国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表

主站蜘蛛池模板: 大同县| 隆德县| 曲周县| 阿鲁科尔沁旗| 瓦房店市| 竹溪县| 德阳市| 肇东市| 平安县| 无极县| 德惠市| 喀什市| 科技| 屏边| 丹凤县| 张家口市| 长子县| 河池市| 肇东市| 扶绥县| 根河市| 巴塘县| 蓬莱市| 黄大仙区| 罗定市| 屏东市| 新河县| 望奎县| 东光县| 赣榆县| 梅河口市| 龙州县| 霍林郭勒市| 鄂尔多斯市| 许昌县| 开远市| 宁晋县| 宝应县| 上犹县| 天峻县| 广灵县|