This article mainly introduces the increasing and decreasing of strings in PHP. For more information, see the following section in the php manual:
"When dealing with arithmetic operations on character variables, PHP follows the Perl habit, not C. For example, in Perl, $ a = 'Z'; $ a ++ changes $ a to 'A', while in C, a = 'Z '; a ++; converts a to '[' (The ASCII value of 'Z' is 90, and the ASCII value of '[' is 91 ). Note that character variables can only increase, cannot decrease, and only letters (a-z and A-Z) are supported ). Other character variables are invalid, and the original string does not change ."
That is to say:
The code is as follows:
For ($ I = 'a'; $ I <= 'Z'; $ I ++ ){
Echo $ I;
// If ($ I = 'zzz') die ();
}
The result is: ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUA ............
Other string variables cannot be decreased:
The code is as follows:
$ A = 'Z ';
-- $;
Echo $ a; // Z
This also indicates that $ a ++ or ++ $ a cannot be interpreted as $ a = $ a + 1;
The code is as follows:
$ A = $ B = 'Z ';
$ A = $ a + 1;
Echo $ a; // 1
+ + $ B;
Echo $ B; // AA
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service