Download! Contributed Code
Is Smarty right for me? Why use it? Crash Course Preface from docs Summary from docs Testimonials
Quick Install Documentation Sample Application Discussion Forums Internet Relay Chat Mailing Lists Smarty Wiki FAQ (from wiki) Other Resources
AOE media TYPO3 Web Hosting @ReviewItOnline Cheap Hosting @HostsVault
www.php.net www.phpinsider.com
Vote for Smarty!
Feel free to put in your rating or review of Smarty at HotScripts.com
Smarty Icon
You may only use the Smarty logo according to the trademark notice
Tell us about it!
Got some news for the front page? New articles, weblog discussions, public talks, etc? Let us know!
テーブルの背景が適切に機能するように を出力する場合のように、空白の変数が何も出力しない代わりに デフォルトの値を出力したい場合があるかもしれません。 そのために多くの人は {if} {if}ステートメントを使用すると思いますが、Smartyによる変数の修飾子 default を使った簡略な方法があります。
注意: "Undefined variable" というエラーが表示されるのは、 PHP の error_reporting() が E_ALL になっており、変数が Smarty に代入されていない場合です。
例 18-1. 変数が空白の時、 を出力する
{* 長ったらしい方法 *} {if $title eq ''} {else} {$title} {/if} {* 簡潔な方法 *} {$title|default:' '}
default 修飾子および 変数のデフォルトの扱い も参照してください。