【问题标题】:A non well formed numeric value encountered - Error in PHP遇到格式不正确的数值 - PHP 中的错误
【发布时间】:2018-06-23 18:00:44
【问题描述】:

我试图在 php 中将两个值相乘,这给了我错误 遇到格式不正确的数值

代码:

$value = 2.5/100;
$totalvalue = $value * $totalvalue;
echo $totalvalue;

【问题讨论】:

  • 你在哪里定义了$totalvalue

标签: php


【解决方案1】:

我忘记打字了。

$value = 2.5/100;
$totalvalue = $value * (float)$totalvalue;
echo $totalvalue;

【讨论】:

    【解决方案2】:

    使用下面的代码:-

    $totalvalue = 1.0 ; //Set $totalvalue and typecast to float
    
    $value = 0.0 ;
    
    $value = 2.5/100;
    
    $totalvalue = $value * $totalvalue;
    
    echo "<br>".$totalvalue;
    

    【讨论】:

      猜你喜欢
      • 2019-11-17
      • 2017-09-13
      • 1970-01-01
      • 2013-05-27
      • 2010-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-15
      相关资源
      最近更新 更多