php将十六进制转义序列转换成字符串

来源:互联网 发布:卡通设计软件 编辑:程序博客网 时间:2024/06/05 22:31
nginx访问日志里的$request_body字段是十六进制转义序列,需要转换成字符串才可以查看。

编写php函数实现:

function hextostr($hex){return preg_replace_callback('/\\\x([0-9a-fA-F]{2})/', function($matches) {return chr(hexdec($matches[1]));}, $hex);}


0 0