简体   繁体   English

php是否内置了对base32值的转换?

[英]Does php have a built in coversion to base32 values?

I know I can use number_format, but is there a way to represent base32 numbers? 我知道我可以使用number_format,但有没有办法表示base32数字? For example, hex can be represented with 0x... and octal can be represented with a 0 in the front. 例如,十六进制可以用0x表示,八进制可以用前面的0表示。 Is there anything to represent base32 numbers in php? 在php中有什么代表base32号码吗?

Use the built-in function base_convert. 使用内置函数base_convert。 For example: 例如:

// To convert from base 10 to base 32:
echo( base_convert( 12345, 10, 32 ) );

我从来没有见过base32的原生符号,但是有一些Base_convert()

number_format() cannot be used to 'represent' a base 32 number, I wonder if you mean base_convert ( http://php.net/base_convert ) to move between bases, eg number_format()不能用来'代表'一个基数为32的数字,我想知道你是否想在base_converthttp://php.net/base_convert )之间移动,例如

echo(base_convert('FF', 16, 10));

As for defining them with a special prefix, as far as I'm aware PHP only supports 0 and 0x for octal/hexadecimal. 至于使用特殊前缀定义它们,据我所知,PHP仅支持八进制/十六进制的0和0x。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM