【问题标题】:Warning: A non-numeric value encountered in handler.php on line 62 [duplicate]警告:在第 62 行的 handler.php 中遇到非数字值 [重复]
【发布时间】:2018-12-11 02:58:13
【问题描述】:

警告:遇到的非数字值 /Applications/XAMPP/xamppfiles/htdocs/cmp255/Final/Change 第 62 行的 Maker/handler.php

我在运行代码时一直看到此错误。
这是第 62 行

$fiveC = 0.05 * $_POST['fiveCent'];


这是它获取数据的来源

<p>$0.05<input type="number" name="fiveCent" ></p>

我能得到任何帮助吗?

【问题讨论】:

  • 新人不会得到与他们的代码无关的某些东西

标签: php


【解决方案1】:

我会在传入的 POST 参数上调用 floatval 以将其转换为浮点值,无论是字符串还是类似浮点数。

所以试试

       $fiveC = 0.05 * floatval($_POST['fiveCent']);

【讨论】:

  • Cody 非常感谢您回答这个问题真的很有帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多