为什么你可以增加PHP中的字符

PHP中,您可以像这样增加一个字符:

$b = 'a'++;

我想知道的是从语言的角度来看为什么行得通? PHP是否将字符解释为ASCII值,所以增加它只会使ASCII值高1,这将是字母表中的下一个字母?

解决方法:

查看此:http://php.net/manual/en/language.operators.increment.php

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 alphabets and digits (a-z, A-Z and 0-9) are supported. Incrementing/decrementing other character variables has no effect, the original string is unchanged.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...