<bdo id='hdKaG'></bdo><ul id='hdKaG'></ul>
  • <tfoot id='hdKaG'></tfoot>

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

      1. <legend id='hdKaG'><style id='hdKaG'><dir id='hdKaG'><q id='hdKaG'></q></dir></style></legend>
        <i id='hdKaG'><tr id='hdKaG'><dt id='hdKaG'><q id='hdKaG'><span id='hdKaG'><b id='hdKaG'><form id='hdKaG'><ins id='hdKaG'></ins><ul id='hdKaG'></ul><sub id='hdKaG'></sub></form><legend id='hdKaG'></legend><bdo id='hdKaG'><pre id='hdKaG'><center id='hdKaG'></center></pre></bdo></b><th id='hdKaG'></th></span></q></dt></tr></i><div id='hdKaG'><tfoot id='hdKaG'></tfoot><dl id='hdKaG'><fieldset id='hdKaG'></fieldset></dl></div>
      2. 在 PHP 中将大整数转换为完整字符串

        Convert a big integer to a full string in PHP(在 PHP 中将大整数转换为完整字符串)

          <tbody id='mMtBQ'></tbody>

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

          <tfoot id='mMtBQ'></tfoot>
              • <small id='mMtBQ'></small><noframes id='mMtBQ'>

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

                  本文介绍了在 PHP 中将大整数转换为完整字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经搜索了一段时间,但我能找到的不是我要搜索的.我需要将一个整数值(可能非常大)转换为字符串.听起来很简单:"$var"?不,因为这会导致数字的 E+ 表示.

                  I've been searching for a while now, but what I can find is not what I search for. I need to convert an integer value, that may be very huge, to a string. Sounds easy: "$var"? No, because this can lead to the E+ representation of the number.

                  <?php
                  
                  $var = 10000000000000000000000000;
                  echo $var."
                  ";
                  echo "'$var'
                  ";
                  echo (string) $var."
                  ";
                  echo strval($var);
                  
                  ?>
                  

                  1.0E+25
                  '1.0E+25'
                  1.0E+25
                  1.0E+25
                  

                  我怎样才能让输出变成 10000000000000000000000000?

                  How can I make the output be 10000000000000000000000000 instead?

                  推荐答案

                  这不是被 PHP 存储为整数,而是一个浮点数,这就是为什么你最终得到 1.0E+25 而不是 10000000000000000000000000.

                  This is not stored as an integer by PHP, but a float, this is why you end up with 1.0E+25 instead of 10000000000000000000000000.

                  遗憾的是,不能在 PHP 中将其用作整数值,因为 PHP 无法保存该大小的整数.如果这来自数据库,那么它将是一个字符串,您可以随心所欲地使用它.如果您将其存储在其他地方,则将其存储为字符串.

                  It's sadly not possible to use that as an integer value in PHP, as PHP cannot save an integer of that size. If this comes from database then it will be a string and you can do with it whatever you want. If you store it elsewhere then store it as a string.

                  您的替代方法是将其存储为浮点数并始终将其考虑在内,尽管这需要额外的转换和处理.

                  Your alternative is to store it as a float and take that into account at all times, though that requires additional conversions and handling in places.

                  也有人建议使用 GNU Multiple Precision,但默认情况下在 PHP 中未启用.

                  It's also been suggested to use GNU Multiple Precision, but that's not enabled in PHP by default.

                  $int=gmp_init("10000000000000000000000000");
                  $string=gmp_strval($int);
                  echo $string;
                  

                  这篇关于在 PHP 中将大整数转换为完整字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)

                    <small id='7o5rX'></small><noframes id='7o5rX'>

                      <tbody id='7o5rX'></tbody>
                    • <bdo id='7o5rX'></bdo><ul id='7o5rX'></ul>
                    • <i id='7o5rX'><tr id='7o5rX'><dt id='7o5rX'><q id='7o5rX'><span id='7o5rX'><b id='7o5rX'><form id='7o5rX'><ins id='7o5rX'></ins><ul id='7o5rX'></ul><sub id='7o5rX'></sub></form><legend id='7o5rX'></legend><bdo id='7o5rX'><pre id='7o5rX'><center id='7o5rX'></center></pre></bdo></b><th id='7o5rX'></th></span></q></dt></tr></i><div id='7o5rX'><tfoot id='7o5rX'></tfoot><dl id='7o5rX'><fieldset id='7o5rX'></fieldset></dl></div>

                            <legend id='7o5rX'><style id='7o5rX'><dir id='7o5rX'><q id='7o5rX'></q></dir></style></legend><tfoot id='7o5rX'></tfoot>