本文介绍了是否在手册中的某处解释了此php行为? (带有零的字符串比较)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么要使用PHP
'00' == '0000'
表达式是true
?
它在手册中的某处进行了解释吗?
Is it explained somewhere in manual?
注意:
此:
不适合这种情况,两个操作数都是字符串.
isn't suitable for the case, both operands are strings.
推荐答案
如果将数字与字符串进行比较,或者比较涉及数字字符串,则每个字符串都将转换为数字,并以数字方式进行比较." ( PHP手册)
"If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically." (PHP manual)
这篇关于是否在手册中的某处解释了此php行为? (带有零的字符串比较)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!