该
<=>(“飞船”),运营商将提供,它会合并比较:
Return 0 if values on either side are equalReturn 1 if the value on the left is greaterReturn -1 if the value on the right is greater
组合比较运算符使用的规则与PHP
viz当前使用的比较运算符相同。
<,
<=,
==,
>=和
>。那些来自Perl或Ruby编程背景的人可能已经熟悉为PHP7建议的这个新运算符。
//Comparing Integers echo 1 <=> 1; //output 0 echo 3 <=> 4; //output -1 echo 4 <=> 3; //output 1 //String Comparison echo "x" <=> "x"; //output 0 echo "x" <=> "y"; //output -1 echo "y" <=> "x"; //output 1
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)