dongtangyi8962 2015-12-02 22:00
浏览 43
已采纳

过滤和消毒整数和浮标 - 我可以加零吗?

I'm using PHP, I've read various posts on sanitizing/filtering and am happy with how I both save and read/represent my data.

But... When it comes to numeric data, my filtering/sanitizing deleted the decimal point.

As a solution, can I not have the server just do a computation on the client data and add zero to the value sent? This implies if the user/client was to send the server non-numeric (perhaps some sql injection string), their ill intent would fail as my string would result in zero.

Acceptable or no? Can anyone forsee a weakness in this?

I ask because I have tried to use

$str=filter_var( $str, FILTER_SANITIZE_NUMBER_FLOAT );

and it removed the decimal point. By adding a zero, I can ensure decimal place is kept.

(thanks in advance)

  • 写回答

1条回答 默认 最新

  • duan6832168 2016-12-19 14:26
    关注

    Based on the comments above... Adding zero to a variable is workable and acceptable though not clear to everyone.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)