Smarty的安装
smarty是一個(gè)PHP模板引擎,用于區(qū)分美工與程序
可以在www.smarty.net官方網(wǎng)站下載,有smarty 2.X、smarty 3.X,smarty 3生成的編譯后的文件很大,暫時(shí)使用Smarty 2
Smarty/libs包含了核心文件
test.php
[php]?view plaincopy print?
[html]?view plaincopy print?
如果是現(xiàn)在這種{}標(biāo)簽,js會(huì)出問(wèn)題,因?yàn)樵趈s中會(huì)用到{},在smarty編譯時(shí)會(huì)將其當(dāng)作是smarty要編譯的東西,會(huì)出錯(cuò)。
例index.html
[html]?view plaincopy print?
Fatal error: Smarty error: [in index.html line 7]: syntax error: unrecognized tag: alert('11111111111111'); (Smarty_Compiler.class.php, line 446) in?D:\AppServ\www\Smarty\libs\Smarty.class.php?on line?1093
可以用literal來(lái)忽略{},
[html]?view plaincopy print?
但是一般都是修改smarty的標(biāo)簽,來(lái)解決這個(gè)問(wèn)題
[php]?view plaincopy print?
在模板中使用變量就可以直接用 <{$name}>
總結(jié)
- 上一篇: 15个初学者必看的基础SQL查询语句
- 下一篇: Smarty中的变量