function hexEncode($s) {
return preg_replace('/(.)/es',"str_pad(dechex(ord('\\1')),2,'0',STR_PAD_LEFT)",$s);
}
function hexDecode($s) {
return preg_replace('/(\w{2})/e',"chr(hexdec('\\1'))",$s);
}
echo hexDecode(hexEncode("北京\n欢迎您!"));
?>
PHP网络编程 | MYSQL数据库 |
没有评论:
发表评论