dqc18251 2013-03-29 06:24
浏览 68

PHP函数is_int()有什么用?

I just wonder why php have a function like is_int(). Documentation says that

To test if a variable is a number or a numeric string (such as form input, which is always a string)

I am sure that no one will ever have to check the type of a variable that is statically assigned. So someone please tell me will there be any situation, where the function is_int() really useful ?

  • 写回答

4条回答 默认 最新

  • doushi3803 2013-03-29 06:31
    关注

    complete understding soluation....

    this is code

     <?php
      $values = array(23, "23", 23.5, "23.5", null, true, false);
      foreach ($values as $value) {
       echo "is_int(";
      var_export($value);
        echo ") = ";
           var_dump(is_int($value));
         }
           ?>
    

    this is output

         is_int(23) = bool(true)
         is_int('23') = bool(false)
        is_int(23.5) = bool(false) 
       is_int('23.5') = bool(false) 
         is_int(NULL) = bool(false)
        is_int(true) = bool(false)
          is_int(false) = bool(false)
    
    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)