PHP:非常简单的Encode/Decode字符串

Ale*_*lex 2 php string int encode decode

是否有任何PHP函数将字符串编码为int值,稍后我可以将其解码回没有任何键的字符串?

pr1*_*001 5

当然,您可以将字符串转换为数字,反之亦然.考虑:

$a = "" + 1
gettype($a) // integer
$b = "$a"
gettype($b) // string
Run Code Online (Sandbox Code Playgroud)

您也可以使用settype()进行类型转换.

如果我误解了你并想要编码任意字符串,请考虑使用base64_encode()bas64_decode().如果要将基本64字符串表示形式转换为基数为10的整数,只需使用base_convert().