thinkphp 运算符

我们可以对模板输出使用运算符,包括对“+”“ –” “*” “/”和“%”的支持。

大理石平台厂家

例如:

运算符 使用示例
+ {$a+$b}
- {$a-$b}
* {$a*$b}
/ {$a/$b}
% {$a%$b}
++ {$a++} 或 {++$a}
-- {$a--} 或 {--$a}
综合运算 {$a+$b*10+$c}

在使用运算符的时候,不再支持点语法和常规的函数用法,例如:

  1. {$user.score+10} //错误的
  2. {$user['score']+10} //正确的
  3. {$user['score']*$user['level']} //正确的
  4. {$user['score']|myFun*10} //错误的
  5. {$user['score']+myFun($user['level'])} //正确的
 

猜你喜欢

转载自www.cnblogs.com/furuihua/p/11821701.html
今日推荐