Mar*_*ski 14
使用pack()和unpack():
function hex2str( $hex ) {
return pack('H*', $hex);
}
function str2hex( $str ) {
return array_shift( unpack('H*', $str) );
}
$txt = 'This is test';
$hex = str2hex( $txt );
$str = hex2str( $hex );
echo "{$txt} => {$hex} => {$str}\n";
Run Code Online (Sandbox Code Playgroud)
会产生
这是测试=> 546869732069732074657374 =>这是测试
| 归档时间: |
|
| 查看次数: |
25647 次 |
| 最近记录: |