drmqzb5063 2014-11-21 00:21
浏览 37
已采纳

PHP将0检查为false [重复]

This question already has an answer here:

I am creating a cropping algorithm and at some point checking if values exists through

if($x && $y){ //then crop }

Which checks if the initial coordinates of the cropping area are specified. However, this fails at the boundaries, because if any of the values are zero (cropping from the border), then php evaluates it as false.

How can I overcome that?

</div>
  • 写回答

2条回答 默认 最新

  • dongyue0225 2014-11-21 00:24
    关注

    Use isset() to check if a variable is set and is not NULL:

    if(isset($x) && isset($y)) { //then crop }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试