PHP:为什么需要字符串比较函数? [英] PHP: Why do we need string comparison function?

查看:19
本文介绍了PHP:为什么需要字符串比较函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比较运算符 <<= >>= 也可以应用于字符串.那么为什么我们需要特殊的字符串比较函数:strcmp?

The comparision operators < <= > >= can be applied for strings as well. So why do we need special function for string comparision: strcmp ?

推荐答案

因为有几种变体:

根据功能,这些问题的答案各不相同:

Depending on the function, the answer to these questions vary:

此外,比较运算符还给出 truefalse.strcmp 给出一个整数,因此它可以同时编码是否存在身份(返回 0),或者如果没有,则更大(取决于值是正数还是负数).

Additionaly, the comparison operators also give true or false. strcmp gives an integer so it can encode simultaneously whether there's identity (return 0) or, if it not, which is is bigger (depending on whether the value is positive or negative).

这篇关于PHP:为什么需要字符串比较函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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