【发布时间】:2016-09-07 04:16:50
【问题描述】:
在 PHP 7 中,我们有一个新的运算符,宇宙飞船运算符<=>,我发现它与strcmp() 非常相似(如果不相同)。
它们之间有什么区别吗?
编辑:我问他们两者之间的区别,没有提到What is <=> (the 'Spaceship' Operator) in PHP 7?或What is <=> (the 'Spaceship' Operator) in PHP 7?
【问题讨论】:
-
来自RFC
Similar to strcmp() or version_compare() in behavior, but it can be used on all generic PHP values with the same semantics as <, <=, ==, >=, >.。 -
@MarcosPérezGude 我看到了那个,但没有回答我的问题。我的问题是有什么区别,我没有看到任何参考。
-
strcmp比较字符串,<=>比较不同的数据类型。 -
好的,抱歉,我撤回投票