php中smarty模板條件判斷用法實例
更新時間:2015年06月11日 11:58:53 作者:zhuzhao
這篇文章主要介紹了php中smarty模板條件判斷用法,實例分析了smarty模板條件判斷的使用技巧,需要的朋友可以參考下
本文實例講述了php中smarty模板條件判斷用法。分享給大家供大家參考。具體實現(xiàn)方法如下:
模板文件test6.html代碼:
<html> <head> <title>Smarty Test</title> </head> <body> <table width="200" border="0"> {if $cond == 1} <tr> <td>條件成立</td> </tr> {else} <tr> <td>條件不成立</td> </tr> {/if} </table> </body> </html>
php代碼:
<?php require 'libs/Smarty.class.php'; //包含Smarty類庫文件 $smarty = new Smarty; //創(chuàng)建一個新的Smarty對象 $cond = 1; $smarty->assign("cond",$cond); //對模版中的變量賦值 $smarty->display('test6.htm'); //顯示頁面 ?>
希望本文所述對大家的php程序設(shè)計有所幫助。
相關(guān)文章
php實現(xiàn)的太平洋時間和北京時間互轉(zhuǎn)的自定義函數(shù)分享
這篇文章主要介紹了php實現(xiàn)的太平洋時間和北京時間互轉(zhuǎn)的自定義函數(shù)分享,主要靠date_default_timezone_set函數(shù)來實現(xiàn),需要的朋友可以參考下2014-08-08Win10 下安裝配置IIS + MySQL + nginx + php7.1.7
本文給大家分享的是在WIN10系統(tǒng)中,安裝配置IIS + MySQL5.7.19 + nginx1.12.1 + php7.1.7的詳細(xì)教程,非常實用,有需要的小伙伴可以參考下2017-08-08