PHP 十六进制
<?php
$str = "http://www.21andy.com";
$andy = '';
for ( $i = 0; $i < strlen($str); $i++ ) {
$andy .= '\x'.base_convert(ord($str[$i]), 10, 16);
}
echo $andy;
?>
$str = "http://www.21andy.com";
$andy = '';
for ( $i = 0; $i < strlen($str); $i++ ) {
$andy .= '\x'.base_convert(ord($str[$i]), 10, 16);
}
echo $andy;
?>
输出结果如下
\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x32\x31\x61\x6e\x64\x79\x2e\x63\x6f\x6d
再这样输出
<?php
echo "\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x32\x31\x61\x6e\x64\x79\x2e\x63\x6f\x6d";
?>
echo "\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x32\x31\x61\x6e\x64\x79\x2e\x63\x6f\x6d";
?>
输出结果如下
http://www.21andy.com