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

带有数字PHP的if语句中的逻辑

Can someone explain what's happening here:

if(2 && 5 < 4)

If i've got for example

$x = 2 && 3;

and var_dump($x) it gives boolean(true) no matter what numbers are. But here it looks like numbers are comparing to 4 one by one.

Look at the PHP comparison table for PHP http://php.net/manual/en/types.comparisons.php

For integers a number other than 0 returns true in comparison.

if (2 && 5 < 4) => if (true && false) => false

$x = 2 && 3 = 1 && 1 = 1

because if a variable has an integer value, true becomes 1 because of type conversion.

近期文章

  • 在PHP中哪个更好Mysql vs Mysqli [重复]
  • Zend Framework小部件教程问题
  • 如何通过AJAX,PHP传递复选框值?
  • 插入图像错误,文本工作正常
  • w3c验证器API - 测试XHTML DOCTYPE
  • 如何从mysql中的json中提取数据
  • 在另一个中使用isset结果
  • 我的页脚在某些页面上只是粘性的
  • 如何在TCPDF中添加新行(<br>或 )?
  • SESSION中的PHP数组,内容为$ _POST
  • mysql pconnect,当它关闭连接时
  • 接受来自唯一推荐人的访问者
  • 无法通过网址从URL解码json
  • (DI)为什么我不能在我的PHP代码中执行此操作
  • WebSockets还是定期的Ajax请求? [重复]
  • 如何给这个表边界半径?
  • SyntaxError:JSON中的意外标记t
  • 转储布尔索引时获取null
  • cakephp 3 + Jwt + angular - 401(未经授权)
  • TIMEZONE选择框仅更改为美国

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华