• <small id='PKyzn'></small><noframes id='PKyzn'>

    <legend id='PKyzn'><style id='PKyzn'><dir id='PKyzn'><q id='PKyzn'></q></dir></style></legend>

        • <bdo id='PKyzn'></bdo><ul id='PKyzn'></ul>

      1. <i id='PKyzn'><tr id='PKyzn'><dt id='PKyzn'><q id='PKyzn'><span id='PKyzn'><b id='PKyzn'><form id='PKyzn'><ins id='PKyzn'></ins><ul id='PKyzn'></ul><sub id='PKyzn'></sub></form><legend id='PKyzn'></legend><bdo id='PKyzn'><pre id='PKyzn'><center id='PKyzn'></center></pre></bdo></b><th id='PKyzn'></th></span></q></dt></tr></i><div id='PKyzn'><tfoot id='PKyzn'></tfoot><dl id='PKyzn'><fieldset id='PKyzn'></fieldset></dl></div>
        <tfoot id='PKyzn'></tfoot>

        将字符串与整数进行比较会产生奇怪的结果

        时间:2023-07-15
        <i id='OaXvM'><tr id='OaXvM'><dt id='OaXvM'><q id='OaXvM'><span id='OaXvM'><b id='OaXvM'><form id='OaXvM'><ins id='OaXvM'></ins><ul id='OaXvM'></ul><sub id='OaXvM'></sub></form><legend id='OaXvM'></legend><bdo id='OaXvM'><pre id='OaXvM'><center id='OaXvM'></center></pre></bdo></b><th id='OaXvM'></th></span></q></dt></tr></i><div id='OaXvM'><tfoot id='OaXvM'></tfoot><dl id='OaXvM'><fieldset id='OaXvM'></fieldset></dl></div>
      2. <tfoot id='OaXvM'></tfoot>

        <small id='OaXvM'></small><noframes id='OaXvM'>

              <legend id='OaXvM'><style id='OaXvM'><dir id='OaXvM'><q id='OaXvM'></q></dir></style></legend>
                <tbody id='OaXvM'></tbody>
                  <bdo id='OaXvM'></bdo><ul id='OaXvM'></ul>
                  本文介绍了将字符串与整数进行比较会产生奇怪的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我真的很困惑为什么这个操作有效.有人能解释一下吗?

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

                  $test1 = "d85d1d81b25614a3504a3d5601a9cb2e";
                  $test2 = "3581169b064f71be1630b321d3ca318f";
                  
                  if ($test1 == 0)
                    echo "Test 1 is Equal!?";
                  if ($test2 == 0)
                    echo "Test 2 is Equal!?";
                  
                  // Returns: Test 1 is Equal!?
                  

                  为了澄清起见,我试图将字符串 "0"$test 变量进行比较.我已经知道要修复我可以将 ""s

                  For clarification, I am trying to compare the string "0" to the $test variables. I already know to fix the code I can just enclose (as I should have) the 0 in ""s

                  我想知道这是 PHP 错误、服务器错误还是某种有效操作.根据http://us3.php.net/types.comparisons,这不应该 成功了.

                  I'm wondering if this is a PHP bug, a server bug, or somehow a valid operation. According to http://us3.php.net/types.comparisons this should not have worked.

                  从头开始,显然它确实提到字符串和 0 之间的松散比较是正确的.但我还是不知道为什么.

                  Scratch that, apparently it does mention that Loose comparisons between string and 0 is true. But I still don't know why.

                  编辑 2: 我已经修改了我的问题,为什么 "3581169b064f71be1630b321d3ca318f"$test2 值不起作用?

                  Edit 2: I've revised my question, why does the $test2 value of "3581169b064f71be1630b321d3ca318f" not work?

                  推荐答案

                  来自 PHP 手册:

                  字符串转数字

                  当一个字符串在一个数字上下文,结果值和类型确定如下.

                  When a string is evaluated in a numeric context, the resulting value and type are determined as follows.

                  该字符串将被评估为浮动,如果它包含任何字符."、e"或E".否则,它将被评估为整数.

                  The string will be evaluated as a float if it contains any of the characters '.', 'e', or 'E'. Otherwise, it will be evaluated as an integer.

                  值由初始值给出字符串的一部分.如果字符串以有效的数字数据开头,这将是使用的值.否则,值将为 0(零).有效数字data 是一个可选的符号,后跟一位或多位数字(可选包含小数点),然后通过一个可选的指数.指数是一个 'e' 或 'E' 后跟一个或更多数字.

                  The value is given by the initial portion of the string. If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero). Valid numeric data is an optional sign, followed by one or more digits (optionally containing a decimal point), followed by an optional exponent. The exponent is an 'e' or 'E' followed by one or more digits.

                  这篇关于将字符串与整数进行比较会产生奇怪的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:cURL 作为代理,处理 HTTPS/CONNECT 方法 下一篇:PHP如何将字符串转换为数字?

                  相关文章

                    <bdo id='NpLdY'></bdo><ul id='NpLdY'></ul>

                • <small id='NpLdY'></small><noframes id='NpLdY'>

                      <legend id='NpLdY'><style id='NpLdY'><dir id='NpLdY'><q id='NpLdY'></q></dir></style></legend>
                      <i id='NpLdY'><tr id='NpLdY'><dt id='NpLdY'><q id='NpLdY'><span id='NpLdY'><b id='NpLdY'><form id='NpLdY'><ins id='NpLdY'></ins><ul id='NpLdY'></ul><sub id='NpLdY'></sub></form><legend id='NpLdY'></legend><bdo id='NpLdY'><pre id='NpLdY'><center id='NpLdY'></center></pre></bdo></b><th id='NpLdY'></th></span></q></dt></tr></i><div id='NpLdY'><tfoot id='NpLdY'></tfoot><dl id='NpLdY'><fieldset id='NpLdY'></fieldset></dl></div>

                    1. <tfoot id='NpLdY'></tfoot>