程序中$order['quantity']*$team['team_price'] 用了乘法,就得出数据40
用了$order['quantity']+$team['team_price']用了加法,就显示字符串链接了。请教哪位能帮忙

解决方案 »

  1.   

    你这少需要给出你那个表达式的应用场合吧
    如果我问你 A*B 就做了乘法,而 A+B 就变成字符串连接了 你该如何做答呢?
      

  2.   

    (float)$order['quantity'] + (float)$team['team_price']
    或者用int,看需要估计,至少$order['quantity']是个数字字符串
      

  3.   

    显然你是透过 input type=text 控件完成计算的但你不说清楚,是你没法帮你的
    我是在网页上计算购买的总金额,本来是从数据库取数出来做乘法,现在要改成做加法就不对了
      

  4.   

    转换为数字再计算:
    如果是整数
    intval($order['quantity'])+intval($team['team_price']);
      

  5.   

    不妨加个问号:
    ($order['quantity']+$team['team_price'])