求解php字符串==的问题?
phpcn_u233
phpcn_u233 2017-03-17 14:19:27
0
2
942
if(0=='0') {echo "0=='0'"; }if(0=='') {echo "0==''"; }if('0'=='') {echo "'0'==''"; }

输出0=='0'0==''为什么最后一个不相等呢?

phpcn_u233
phpcn_u233

reply all (2)
数据分析师

Solve the problem of php string ==? -PHP Chinese website Q&A-How to solve the problem of php string ==? -PHP Chinese website Q&A

Let’s take a look and learn.

    阿神

    这三个if判断,前两个是数值比较,最后一个是字符串比较;

    前两个数值比较,会将字符串转换成数字

    按照规则:如果字符串以合法的数字数据开始,就用该数字作为其值,否则其值为 0(零);

    最后的字符串比较,就是单纯的字符串之间判断是否相同;

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!