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 中执行此 Perl 代码?
print unpack ("H*", pack ("B*", "00000000100000012000000" ));
由于 PHP 中的打包/解包不支持 B 类型,因此您必须使用 PHP 的其他函数。在这种情况下,dechex和bindec。
dechex
bindec
echo dechex( bindec( "00000000100000012000000" ));
编辑:或者使用 base_convert 在单个函数中执行此操作:
echo base_convert("00000000100000012000000", 2, 16);