smarty四则运算里面怎么用小括号? 本帖最后由 qvbfndcwy 于 2012-04-26 14:28:07 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你应该尽量在php中运算。再assign给模板。另外。你的代码有什么错? 第一行没错:a+b:<{$a+$b}><br />第二行也没错:a/c:<{$a/$c|string_format:"%.2f"}><br />第三行有错:(a+b)/c:<{($a+$b)/$c|string_format:"%.2f"}><br />就是想问第三行要怎么改另外,有十几列数据,要实现的是各列间的各种四则运算,php不可能把各结果都得到了再传给smarty吧。 提示什么错误? php完全可以把各结果得到了再传给smarty。不就是多几个变量或是数组的问题。 好吧,还是回到正题。smarty进行四则运算,优先级怎么定义? 加括号把,由于没有smarty环境。测试不了。看其他朋友怎么说。 <?phprequire_once "include/smarty_config.php";$a=1;$smarty->assign("a",$a);$smarty->display("t.tpl");?><{$a*100+$b*100+$c*100+$d*100}>以上只定义了一个$a=1,传给smarty,但是模板里面的语法<{$a*100+$a*100+$a*100+$a*100}>确实会出错。而改成:<{$a*100+$a*100+$a*100}>就正确了。 smarty中的四则运算已有 567 次阅读2006-12-4 11:14 |个人分类:PHP0{* $height=4, $width=5 *}{math equation="x + y" x=$height y=$width}OUTPUT:9{* $row_height = 10, $row_width = 20, #col_div# = 2, assigned in template *}{math equation="height * width / division" height=$row_height width=$row_width division=#col_div#}OUTPUT:100{* you can use parenthesis *}{math equation="(( x + y ) / z )" x=2 y=10 z=2}OUTPUT:6{* you can supply a format parameter in sprintf format *}{math equation="x + y" x=4.4444 y=5.0000 format="%.2f"}OUTPUT:9.44 你必须了解的Session的本质 如何根据一些拼音字符显示出来中文词组 关于ini_set()的问题 php编辑其里都用什么编码啊? phpmyadmin安装问题session.save_path 求一正则 救命!!!preg_replace 正则替换问题. 一时好奇,动态改变图片上文字的php程序怎么做的?给点源代码 已知 赛迪网 三个汉字用文字编辑器转成 UTF8后是乱码。然后用16进制看为 EF BB BF E8 B5 9B E8 BF AA E7 BD 91 在网页中进行查询 我什么我这里返回不了姓名和年龄 求推荐Php方面以“实战”为写作目的 的经典书目。
第二行也没错:a/c:<{$a/$c|string_format:"%.2f"}><br />
第三行有错:(a+b)/c:<{($a+$b)/$c|string_format:"%.2f"}><br />
就是想问第三行要怎么改另外,有十几列数据,要实现的是各列间的各种四则运算,php不可能把各结果都得到了再传给smarty吧。
smarty进行四则运算,优先级怎么定义?
require_once "include/smarty_config.php";
$a=1;
$smarty->assign("a",$a);
$smarty->display("t.tpl");
?>
<{$a*100+$b*100+$c*100+$d*100}>以上只定义了一个$a=1,传给smarty,但是模板里面的语法
<{$a*100+$a*100+$a*100+$a*100}>
确实会出错。而改成:
<{$a*100+$a*100+$a*100}>
就正确了。
已有 567 次阅读2006-12-4 11:14 |个人分类:PHP
0
{* $height=4, $width=5 *}
{math equation="x + y" x=$height y=$width}
OUTPUT:
9
{* $row_height = 10, $row_width = 20, #col_div# = 2, assigned in template *}
{math equation="height * width / division"
height=$row_height
width=$row_width
division=#col_div#}
OUTPUT:
100
{* you can use parenthesis *}
{math equation="(( x + y ) / z )" x=2 y=10 z=2}
OUTPUT:
6
{* you can supply a format parameter in sprintf format *}
{math equation="x + y" x=4.4444 y=5.0000 format="%.2f"}
OUTPUT:
9.44