douzuqin3467 2013-08-24 18:19
浏览 58
已采纳

这个if语句如何评估为true?

if ($opts['width'] == 'fs' || $opts['height'] == 'fs' || $opts['ratio'] == 'fs') {
    var_dump($opts); // result of this see bellow
}

Result of var_dump($opts) inside (!) if-statement:

array(3) {
   'width' => int(200)
   'height' => int(0)
   'ratio' => int(0)
}

How is this possible? None of the array's values is (stirng) fs?

  • 写回答

1条回答 默认 最新

  • duanliao6789 2013-08-24 18:20
    关注

    Because 0 == 'fs'. See this conversion table.

    PHP has the === operator to compare both value and type.

    For a more extensive table: Type-juggling and (strict) greater/lesser-than comparisons in PHP

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

报告相同问题?

悬赏问题

  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀