• <legend id='aMYi0'><style id='aMYi0'><dir id='aMYi0'><q id='aMYi0'></q></dir></style></legend>

  • <tfoot id='aMYi0'></tfoot>

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

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

        PHP 类型转换

        时间:2023-09-25
      1. <legend id='jU1RN'><style id='jU1RN'><dir id='jU1RN'><q id='jU1RN'></q></dir></style></legend>

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

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

      2. <tfoot id='jU1RN'></tfoot>

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

                • 本文介绍了PHP 类型转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想知道将值从一种类型转换为另一种类型的最佳方法是什么.

                  I was wondering what is the best way to typecast a value from one type to another.

                  我们应该使用哪种变体:

                  Which variant should we use:

                  1. intval($value);
                  2. settype($value, 'int')
                  3. (int)$value

                  所有这些都产生相同的结果.

                  All of them produce same result.

                  推荐答案

                  (int)$value
                  

                  intval($value)settype($value, 'int') 相比,节省了一个函数调用.

                  saves one function call compares to intval($value) and settype($value, 'int').

                  而且 (int)$value 已经足够干净了,所以我更喜欢这种方式.

                  And (int)$value is clean enough, so I prefer this way.

                  When you need to use intval($value) 是当你需要使用指定的基数进行转换时(默认为基数 10).intval 接受第二个参数作为转换的基础.

                  When you need to use intval($value) is that when you need to use the specified base for the conversion (the default is base 10). intval accepts a second parameter for the base for the conversion.

                  这篇关于PHP 类型转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 PHP 中处理货币值的最佳实践? 下一篇:如何在 PHP 中创建 websockets 服务器

                  相关文章

                  最新文章

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

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

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

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