“不相等"与“不相等"之间的区别在于:运算符<>和!=在PHP中 [英] Difference between "not equal" operators <> and != in PHP

查看:62
本文介绍了“不相等"与“不相等"之间的区别在于:运算符<>和!=在PHP中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP中,!=<>运算符之间有什么区别吗?

In PHP, is there any difference between the != and <> operators?

手册中,指出:

$a != $b    Not equal   TRUE if $a is not equal to $b after type juggling.
$a <> $b    Not equal   TRUE if $a is not equal to $b after type juggling.

我想没有太大的区别,但我很好奇.

I guess there are no huge differences but I'm curious.

推荐答案

在Zend的主要实现中,没有任何区别.您可以从PHP语言 Flex 描述中获得它/repository/php/php-src/trunk/Zend/zend_language_scanner.l>扫描仪:

In the main Zend implementation there is not any difference. You can get it from the Flex description of the PHP language scanner:

<ST_IN_SCRIPTING>"!="|"<>" {
    return T_IS_NOT_EQUAL;
}

其中T_IS_NOT_EQUAL是生成的令牌.因此野牛

Where T_IS_NOT_EQUAL is the generated token. So the Bison parser does not distinguish between <> and != tokens and treats them equally:

%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL
%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL

这篇关于“不相等"与“不相等"之间的区别在于:运算符&lt;&gt;和!=在PHP中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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