简体   繁体   English

优先级如何与PHP中的比较运算符一起使用?

[英]How does the precedence is working with comparison operators in PHP?

I'm using PHP 7.2.0 我正在使用PHP 7.2.0

I wrote following code : 我写了以下代码:

<?php
echo 1 <= 5 == 1;
?>

and I got following output in my web browser : 我在网络浏览器中得到以下输出:

1

I expected none(false) or 0 to be the output but surprisingly I got 1 as an output. 我期望none(false)或0为输出,但令人惊讶的是我得到1作为输出。

I'm not able to understand how does the precedence get worked out here. 我不明白这里如何计算优先级。

Can someone please explain me how the precedence got worked in this code in a step-by-step manner? 有人可以逐步解释一下优先级如何在此代码中起作用吗?

Thank You. 谢谢。

1 <= 5 is true , 1 <= 5true
true == 1 is true , true == 1true
echo true outputs 1 . echo true输出1

The precedence is: 优先级是:

echo (1 <= 5) == 1;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM