to thus trying to increment a string and are blocked by the exponential typecast explained in the message below, here is a small function :
function increment($var) {
$var2 = '_'.$var;
return substr(++$var2,1);
}
![]() | 递增/递减运算符PHP 支持 C 风格的前/后递增与递减运算符。
表格 15-6. 递增/递减运算符
一个简单的示例脚本:
在处理字符变量的算数运算时,PHP 沿袭了 Perl 的习惯,而非 C 的。例如,在 Perl 中 'Z'+1 将得到 'AA',而在 C 中,'Z'+1 将得到 '['(ord('Z') == 90,ord('[') == 91)。注意字符变量只能递增,不能递减。 递增或递减布尔值没有效果。 ![]()
julien-bernie-laurent at polenord.com
01-Mar-2006 11:55
to thus trying to increment a string and are blocked by the exponential typecast explained in the message below, here is a small function :
timo at frenay dot net
25-Aug-2004 11:45
JMcCarthy AT CitiStreet DOT com:
01-Apr-2004 05:19
Note that incrementing strings can give unpredictable results due to type changes. For example:
chris at free-source dot com
07-Feb-2004 08:11
Interesting performance note:
mu at despammed dot net
15-Oct-2002 12:11
The exact moment when post-increment and post-decrement happen is _just immediately after the variable is evaluated_ (not "after the line is processed" or something like that)
cleong at letstalk dot com
18-Oct-2001 10:52
Note that the ++ and -- don't convert a boolean to an int. The following code will loop forever.
fred at surleau dot com
19-Jul-2001 03:02
Other samples :
| ![]() | |||||||||||||||||