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

    1. <small id='N0Neu'></small><noframes id='N0Neu'>

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

        字符串的增量行为 - PHP复活节彩蛋?

        时间:2023-09-25
      1. <i id='Im7BK'><tr id='Im7BK'><dt id='Im7BK'><q id='Im7BK'><span id='Im7BK'><b id='Im7BK'><form id='Im7BK'><ins id='Im7BK'></ins><ul id='Im7BK'></ul><sub id='Im7BK'></sub></form><legend id='Im7BK'></legend><bdo id='Im7BK'><pre id='Im7BK'><center id='Im7BK'></center></pre></bdo></b><th id='Im7BK'></th></span></q></dt></tr></i><div id='Im7BK'><tfoot id='Im7BK'></tfoot><dl id='Im7BK'><fieldset id='Im7BK'></fieldset></dl></div>

          <bdo id='Im7BK'></bdo><ul id='Im7BK'></ul>
              <tbody id='Im7BK'></tbody>

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

                  <tfoot id='Im7BK'></tfoot>

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

                  本文介绍了字符串的增量行为 - PHP复活节彩蛋?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  $var = 'test_1';
                  var_dump(++$var); // string(6) "test_2" 
                  
                  $var2 = '1_test';
                  var_dump(++$var2); // string(6) "1_tesu"
                  
                  $var3 = 'test_z';
                  var_dump(++$var3); // string(6) "test_a"
                  
                  $var4 = 'test_';
                  var_dump(++$var4); // string(5) "test_"
                  

                  很明显,如果最后一个字符是数字,则在字符串上使用增量运算符具有增加数字的效果,如果最后一个字符在字母表中,则增加字母然后重置为一次 z,并且没有对非字母数字字符的影响.

                  So apparently, using an increment operator on a string has the effect of increasing the digit if the last character is a number, increasing the letter and then resetting to a once z if the last character is in the alphabet, and has no effect on non alpha numeric characters.

                  这是许多脚本语言都期望的标准功能,还是我只是找到了一个 PHP 复活节彩蛋?

                  Is this a standard feature, expected in many scripting languages, or did I just find a PHP easter egg?

                  推荐答案

                  PHP 在处理算术运算时遵循 Perl 的约定在字符变量上而不是 C 的.例如,在 PHP 和 Perl 中 $a ='Z';$a++;把 $a 变成 'AA',而在 C a = 'Z';一个++;变成'['('Z'的ASCII值为90,'['的ASCII值为91).注意字符变量可以增加但不能减少,即使如此仅支持纯 ASCII 字符(a-z 和 A-Z).增加/减少其他字符变量没有效果,原始字符串不变.

                  PHP follows Perl's convention when dealing with arithmetic operations on character variables and not C's. For example, in PHP and Perl $a = 'Z'; $a++; turns $a into 'AA', while in C a = 'Z'; a++; turns a into '[' (ASCII value of 'Z' is 90, ASCII value of '[' is 91). Note that character variables can be incremented but not decremented and even so only plain ASCII characters (a-z and A-Z) are supported. Incrementing/decrementing other character variables has no effect, the original string is unchanged.

                  -> http://php.net/manual/en/language.operators.increment.php

                  这篇关于字符串的增量行为 - PHP复活节彩蛋?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:哪个 MySQL 数据类型用于 IP 地址? 下一篇:在 PHP 中处理货币值的最佳实践?

                  相关文章

                  最新文章

                  <small id='8Go8w'></small><noframes id='8Go8w'>

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

                • <legend id='8Go8w'><style id='8Go8w'><dir id='8Go8w'><q id='8Go8w'></q></dir></style></legend>

                    <tfoot id='8Go8w'></tfoot>