'false === $ var'和'$ var === false'有什么区别? [英] What's the difference between 'false === $var' and '$var === false'?

查看:152
本文介绍了'false === $ var'和'$ var === false'有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比另一个更可读吗?首先,我不喜欢 false === 方法,但是我越来越频繁地看到它,我正在热身。我确定他们返回相同的结果。

Is one more readable than the other? At first, I disliked the false === approach but as I see it more and more often, I'm warming up to it. I'm pretty sure they return identical results.

推荐答案

我非常喜欢

false === $var

也就是因为有时候你只是使用平等而不是寻找身份。

Namely because sometimes you are only using equality and not looking for identity.

在这种情况下,您写

false == $var

但有时候你不是在你的游戏的顶部,可能写

But sometimes you aren't at the top of your game, and might write

false = $var



<

which will give an immediate error, and let's you fix it right away.

但是,如果您键入

pre> $ var = false

在墙上一个小时,试图找出为什么你的脚本不能正常工作。

you end up beating your head against a wall for an hour trying to figure out why your script isn't working right.

这篇关于'false === $ var'和'$ var === false'有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆