Chen Log

陳洛格

ThinkPHP tpl 模板變數計算

leave a comment »

輸出變數很簡單,但是要如何讓兩個變數相加呢?

如同下列 {$order.fee_shipping}+{$order.fee_tax}

如果直接這樣打,輸出的結果是空白的。

 

要改成:

{$order[fee_shipping]+$order[fee_tax]}

 

在使用运算符的时候,不再支持点语法和常规的函数用法,
例如:
{$user.score+10} //错误的 {$user[‘score’]+10} //正确的
{$user[‘score’]*$user[‘level’]} //正确的
{$user[‘score’]|myFun*10} //错误的
{$user[‘score’]+myFun($user[‘level’])} //正确的

詳細資料請參考:
http://www.thinkphp.cn/info/154.html

Advertisements

Written by chenagw

2013/06/07 at 15:57

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: