Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要使用 PHP 将数字(字符串)转换为 int8 或 uint8 的帮助。
示例:数字10应该是0A
10
0A
我怎样才能做到这一点?
您想要做的似乎与有符号或无符号整数无关,您只是将整数转换为其十六进制表示。在 PHP 中,可以使用dechex.
dechex
dechex(10)将返回 0xA。
dechex(10)
You can use the following line to convert a number to its hexdecimal string representation
echo dechex(intval("10"));
There is also a Hexdump function available for php. This may help too.
You'll find more info here