?
Dieses Dokument verwendet PHP-Handbuch für chinesische Websites Freigeben
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.
也許有時(shí)候你想給一個(gè)沒(méi)有賦值的變量輸出一個(gè)默認(rèn)的值來(lái)代替什么也不輸出,比如輸出' '[這是一個(gè)空格符號(hào),HTML里的標(biāo)記](méi)來(lái)使得表格里的背景能夠正常工作。大多數(shù)人使用{if}語(yǔ)句來(lái)處理這些,但是用Smatry這里有一個(gè)捷徑,那就是使用 default [默認(rèn)的]值賦給變量。
Example 18-1. Printing when a variable is empty 例 18-1。輸出 ---如果一個(gè)變量是空值
|