最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php簡單smarty入門程序實例

 更新時間:2015年06月11日 11:31:27   作者:zhuzhao  
這篇文章主要介紹了php簡單smarty入門程序,實例分析了smarty模板的配置與使用技巧,需要的朋友可以參考下

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

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

title = Welcome to Smarty!
cutoff_size = 40
[setup]
bold = true

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

<html> 
  <head> 
    <title>Smarty Test</title> 
  </head> 
  <body> 
    <H1>Hello, {$Name}</H1> 
  </body> 
</html> 

php文件代碼:

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

運行后顯示的頁面代碼:

<html> 
  <head> 
    <title>Smarty Test</title> 
  </head> 
  <body> 
    <H1>Hello, Simon</H1> 
  </body> 
</html> 

運行之后,還在templates_c文件夾中生成一個php文件:

<?php
/* Smarty version 2.6.22, created on 2009-03-19 13:20:00 
     compiled from test.htm */
?> 
<html> 
  <head> 
    <title>Smarty Test</title> 
  </head> 
  <body> 
    <H1>Hello, <?php echo $this->_tpl_vars['Name']; ?> 
</H1> 
  </body> 
</html> 

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

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

相關文章

最新評論

浦北县| 建瓯市| 汶上县| 嘉善县| 拉萨市| 衢州市| 芜湖县| 高州市| 文昌市| 巴彦淖尔市| 林州市| 尉氏县| 鄂温| 吴江市| 香港 | 论坛| 宕昌县| 普安县| 时尚| 惠水县| 保亭| 抚远县| 贵州省| 泰顺县| 墨江| 卢龙县| 阆中市| 高台县| 侯马市| 石城县| 苏州市| 来安县| 林口县| 剑川县| 青海省| 扶余县| 新巴尔虎右旗| 大同县| 临颍县| 丰台区| 乌鲁木齐县|