dpzlz08480 2014-03-01 02:33
浏览 221
已采纳

PHP - 如果条件匹配包括小数的精确值

i am trying to match exact number with decimal. i have tried following but doesn't work

tried following code, but doesn't work with decimal.

<?php
$number=1.23;
$numbers=1.28;

if (is_float($number)==is_float($numbers))
{
   echo 'matched';
}else{
   echo 'not matched';
}

?>

please check where i am doing mistake or it's totally wrong way to do that. i have check above in PHP sites.

  • 写回答

2条回答 默认 最新

  • dongli1887 2014-03-01 02:35
    关注

    Use floatval (which returns the float value of the given variable) instead of is_float (which returns true if the given variable is a float and false if it isn’t).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)