?
? ????? PHP ??? ???? ??? ?? ??
There may be times when you want to print a default value for an empty variable instead of printing nothing, such as printing " " so that table backgrounds work properly. Many would use an {if} statement to handle this, but there is a shorthand way with Smarty, using the default variable modifier.
也許有時候你想給一個沒有賦值的變量輸出一個默認(rèn)的值來代替什么也不輸出,比如輸出' '[這是一個空格符號,HTML里的標(biāo)記]來使得表格里的背景能夠正常工作。大多數(shù)人使用{if}語句來處理這些,但是用Smatry這里有一個捷徑,那就是使用 default [默認(rèn)的]值賦給變量。
Example 18-1. Printing when a variable is empty 例 18-1。輸出 ---如果一個變量是空值
|