Comparing String to Integer gives strange results

后端 未结 5 1827
北恋
北恋 2020-11-22 16:41

I\'m really confused as to why this operation works. Can someone explain it?

$test1 = \"d85d1d81b25614a3504a3d5601a9cb2e\";
$test2 = \"3581169b064f71be1630b         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 17:28

    $test1 = "d85d1d81b25614a3504a3d5601a9cb2e";
    

    this string starts with a "d", which is not valid number, the var will resolve to 0 and your test#1 will pass.

    $test2 = "3581169b064f71be1630b321d3ca318f";
    

    this string starts with 3581169 which is a valid number, so the var will resolve to that value which is not equal to 0. So your test#2 will not pass.

提交回复
热议问题