《PHP實戰(zhàn):smarty學(xué)習(xí)筆記之常見代碼段用法總結(jié)》要點:
本文介紹了PHP實戰(zhàn):smarty學(xué)習(xí)筆記之常見代碼段用法總結(jié),希望對您有用。如果有疑問,可以聯(lián)系我們。
本文實例講述了smarty常見代碼段.分享給大家供大家參考,具體如下:PHP編程
1、PHP編程
<select > {html_options values=$cust_ids selected=$customer_id output=$cust_names} </select>
說明:生成下拉菜單.values=一個數(shù)組,數(shù)組元素為列表值 selected=一個值,這個是默認(rèn)的列PHP編程
表值 output=一個數(shù)組,數(shù)組元素為顯示的列表值PHP編程
{html_checkboxes values=$cust_ids checked=$customer_id output=$cust_names separator="<br/>"}
說明:復(fù)選框.同上;separator="<br />"指以<br />分隔每個復(fù)選按鈕的字符串PHP編程
{html_radios values=$cust_ids checked=$customer_id output=$cust_names separator="<br/>"}
說明:單選按鈕PHP編程
2、PHP編程
{counter start=0 skip=2 print=ture}
說明:計數(shù)器,其后使用時,以0 開始,每次增加 2 .PHP編程
3、PHP編程
{section loop=$data} <tr bgcolor="{cycle values="#eeeeee,#d0d0d0"}"> <td>{$data[rows]}</td> </tr> {/section}
說明:輪回返回數(shù)組元素(或一個數(shù)列)值PHP編程
4、PHP編程
{assign var="name" value="Bob"} The value of $name is {$name}.//The value of $name is Bob.
說明:賦值PHP編程
5、PHP編程
{fetch file="http://www.myweather.com/68502/" assign="weather"}
說明:fetch 用于從本地文件系統(tǒng)、HTTP或FTP上取得文件并顯示文件的內(nèi)容. 如果文件名稱?PHP編程
以"http://"開頭,將取得該網(wǎng)站頁面并顯示. 如果文件名稱以"ftp://"開頭,將從ftp服務(wù)器取得PHP編程
該文件并顯示.PHP編程
6、PHP編程
{html_image file="../path/relative/to/currdir/pumpkin.jpg" border="1" height="100" width="100" alt="圖片" href="1.html"}
說明:圖片PHP編程
7、PHP編程
{html_select_date}
說明:創(chuàng)建日期下拉菜單. 它可以顯示任意年月日PHP編程
{html_select_time}
說明:用于創(chuàng)建時間下拉菜單. 它可以顯示任意時分秒PHP編程
8、PHP編程
{html_table loop=$data cols=4 table_attr='border="0"' tr_attr=$tr td_attr=$td}
說明:以$data數(shù)組元素形成一個4列的表.table_attl為表格屬性,tr_attr為行屬性,td_attrPHP編程
為列屬性PHP編程
9、PHP編程
{math equation="x + y" x=$height y=$width}
說明:數(shù)學(xué)運算函數(shù)PHP編程
10、PHP編程
{mailto address="me@domain.com" text="send me some mail"}
說明:生成電子郵件鏈接PHP編程
11、PHP編程
{popup}
說明:創(chuàng)建javascript彈出窗口,使用前必須先調(diào)用 popup_init 函數(shù)PHP編程
希望本文所述對大家基于smarty模板的PHP程序設(shè)計有所贊助.PHP編程
《PHP實戰(zhàn):smarty學(xué)習(xí)筆記之常見代碼段用法總結(jié)》是否對您有啟發(fā),歡迎查看更多與《PHP實戰(zhàn):smarty學(xué)習(xí)筆記之常見代碼段用法總結(jié)》相關(guān)教程,學(xué)精學(xué)透。維易PHP學(xué)院為您提供精彩教程。
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/7298.html