- <?php
-
-
-
-
-
-
-
- function asc2hex($str) {
- return 'x'.substr(chunk_split(bin2hex($str), 2, 'x'),0,-2);
- }
-
- function hex2asc($str) {
- $str = join('',explode('x',$str));
- $len = strlen($str);
- for ($i=0;$i<$len;$i+=2) $data.=chr(hexdec(substr($str,$i,2)));
- return $data;
- }
- $asc = "哈哈";
- $hex = asc2hex($asc);
- $asc = hex2asc($hex);
- echo "hex : ".$hex;
- echo "
- ";
- echo "asc : ".$asc;
- ?>
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)