douyou1901 2019-07-13 03:34
浏览 97

如何打印is_int()的结果

I already know what is_int() is used for. But I only know that to print the result of this function we need to use the var_dump() function. So can someone explain to me why echo, print or print_r() cannot display is_int()?

$var1 = '123';
var_dump(is_int($var1)); // return False;

$var2 = '123';
echo/print/print_r($var2); // Not working
  • 写回答

1条回答 默认 最新

  • dqf35839 2019-07-13 04:38
    关注

    In PHP (boolean) false will be converted to "" (empty string) and boolean (true) will be converted to 1 so when you print_r and the return value is false then you will get the empty string. So either use the var_dump to get the variable details where it will give you the type and value both.

    Here is the way to echo the true and false based on the result. you can use this too

    $var1 = '123';
    echo is_int($var1)?'true':'false';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接