smarty學習筆記之常見代碼段用法總結
本文實例講述了smarty常見代碼段。分享給大家供大家參考,具體如下:
1、
<select >
{html_options values=$cust_ids selected=$customer_id output=$cust_names}
</select>
說明:生成下拉菜單。values=一個數(shù)組,數(shù)組元素為列表值 selected=一個值,這個是默認的列
表值 output=一個數(shù)組,數(shù)組元素為顯示的列表值
{html_checkboxes values=$cust_ids checked=$customer_id
output=$cust_names separator="<br/>"}
說明:復選框。同上;separator="<br />"指以<br />分隔每個復選按鈕的字符串
{html_radios values=$cust_ids checked=$customer_id
output=$cust_names separator="<br/>"}
說明:單選按鈕
2、
{counter start=0 skip=2 print=ture}
說明:計數(shù)器,其后使用時,以0 開始,每次增加 2 。
3、
{section loop=$data}
<tr bgcolor="{cycle values="#eeeeee,#d0d0d0"}">
<td>{$data[rows]}</td>
</tr>
{/section}
說明:輪回返回數(shù)組元素(或一個數(shù)列)值
4、
{assign var="name" value="Bob"}
The value of $name is {$name}.//The value of $name is Bob。
說明:賦值
5、
{fetch file="http://www.myweather.com/68502/" assign="weather"}
說明:fetch 用于從本地文件系統(tǒng)、HTTP或FTP上取得文件并顯示文件的內容. 如果文件名稱
以"http://"開頭,將取得該網(wǎng)站頁面并顯示. 如果文件名稱以"ftp://"開頭,將從ftp服務器取得
該文件并顯示.
6、
{html_image file="../path/relative/to/currdir/pumpkin.jpg"
border="1" height="100" width="100" alt="圖片" href="1.html"}
說明:圖片
7、
{html_select_date}
說明:創(chuàng)建日期下拉菜單. 它可以顯示任意年月日
{html_select_time}
說明:用于創(chuàng)建時間下拉菜單. 它可以顯示任意時分秒
8、
{html_table loop=$data cols=4 table_attr='border="0"'
tr_attr=$tr td_attr=$td}
說明:以$data數(shù)組元素形成一個4列的表。table_attl為表格屬性,tr_attr為行屬性,td_attr
為列屬性
9、
{math equation="x + y" x=$height y=$width}
說明:數(shù)學運算函數(shù)
10、
{mailto address="me@domain.com" text="send me some mail"}
說明:生成電子郵件鏈接
11、
{popup}
說明:創(chuàng)建javascript彈出窗口,使用前必須先調用 popup_init 函數(shù)
希望本文所述對大家基于smarty模板的PHP程序設計有所幫助。
- Ajax+smarty技術實現(xiàn)無刷新分頁
- Zend Framework實現(xiàn)Zend_View集成Smarty模板系統(tǒng)的方法
- Codeigniter中集成smarty和adodb的方法
- PHP文件緩存smarty模板應用實例分析
- yii,CI,yaf框架+smarty模板使用方法
- smarty高級特性之對象的使用方法
- smarty高級特性之過濾器的使用方法
- php實現(xiàn)smarty模板無限極分類的方法
- smarty簡單應用實例
- Smarty使用自定義資源的方法
- smarty中常用方法實例總結
- Smarty最簡單實現(xiàn)列表奇偶變色的方法
- Smarty foreach控制循環(huán)次數(shù)的一些方法
- CodeIgniter中使用Smarty3基本配置
相關文章
簡單的php數(shù)據(jù)庫操作類代碼(增,刪,改,查)
這幾天準備重新學習,梳理一下知識體系,同時按照功能模塊劃分做一些東西。所以。mysql的操作成為第一個要點。我寫了一個簡單的mysql操作類,實現(xiàn)數(shù)據(jù)的簡單的增刪改查功能。2013-04-04
詳解如何實現(xiàn)phpoffice的excel導入功能解耦
這篇文章主要為大家介紹了詳解如何實現(xiàn)phpoffice的excel導入功能解耦,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-05-05

