有同學問了一個問題:
複製程式碼 程式碼如下:
for($i =
for($i = 'A'; $i echo $i;
輸出是:
複製程式碼
程式碼如下:
複製程式碼 程式碼如下:
PHP follows Perl's convention when dealing with arithmetic operations on character variables and not C's. For example, in Perl 'Z'+1 turns into 'AA', while in CZ 'AA', while 在 CZ 'AA', while turns into '[' ( ord('Z') == 90, ord('[') == 91 ). Note that character variables can be incremented but not decremented and even so only plain ASCII characters (a-z and A-Z) and even so only plainlain ASCII characters (a-z and A-Z) and even supported.
複製代碼 代碼如下:
$name = "laruence";
++$name; //將會是"laruencf"
複製程式碼 程式碼如下:
$name = "laruence";--$name; //沒有影響, 還是"laruence"
所以, 這個問題的原因就是當$i = Z的時候, ++$i成了AA, 而字串比較的話,