我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

这个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?

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

近期文章

  • 会话ID为md5(time())
  • redbean 3.4未定义的索引:id
  • php:sum数组值的结果是错误的
  • Twitter typeahead显示'&amp'而不是'&'
  • 简单的PHP回声无法正常工作[重复]
  • PHP创建一个日期为文件名的.txt文件
  • 使用PHP在查询结果中填充下拉列表
  • 通过增加和减少所有顶级索引来重新索引数组
  • 将确认密码与散列密码进行比较 Laravel 4
  • 在文本框后定义php var
  • 在Objective C中签名字符串并在PHP中验证 - 不起作用
  • cURL PHP奇怪的人物
  • 重复输入mysql数据库
  • PHP - 使用explode创建数组
  • php结合if空语句语法
  • 错误的时间计算超过30分钟
  • 使用PHP在命令提示符下运行.bat文件
  • 如何发送大量信息? [关闭]
  • 在pycharm中检查是否相等
  • INSERT 语句与 FOREIGN KEY 约束"fk_zyxbdm"冲突。该冲突发生于数据库"xuanke",表"dbo.系部", column '系部代码'。为什么会这样?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华