• <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>

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

        Comparing String to Integer gives strange results(将字符串与整数进行比较会产生奇怪的结果)
        <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.

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

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <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>

                            <tbody id='NpLdY'></tbody>
                          • <tfoot id='NpLdY'></tfoot>