本文共 862 字,大约阅读时间需要 2 分钟。
php
//a字符
$str=(pack("a*", "中国"));
echo $str,"=",strlen($str),"字节n";
getascill($str);
//h字符
$str=(pack("h*", "fffe"));
echo $str,"=",strlen($str),"字节n";
getascill($str);
//c字符
$str=(pack("c*", "55","56","57"));
echo $str,"=",strlen($str),"字节n";
getascill($str);
//i字符 短整形 32位 4个字节 64位8个字节
$str=(pack("i", "100"));
echo $str,"=",strlen($str),"字节n";
getascill($str);
//s字符 短整形 2个字节
$str=(pack("s", "100"));
echo $str,"=",strlen($str),"字节n";
getascill($str);
//l字符 长整形 4个字节
$str=(pack("l", "100"));
echo $str,"=",strlen($str),"字节n";
getascill($str);
//f字符 单精度浮点 4个字节
$str=(pack("f", "100"));
echo $str,"=",strlen($str),"字节n";
getascill($str);
//d字符 双精度浮点 8个字节
$str=(pack("d", "100"));
echo $str,"=",strlen($str),"字节n";
getascill($str);
function getascill($str)
{
$arr=str_split($str);
foreach ($arr as $v)
{
echo $v,"=",ord($v),"n";
}
echo "=============rnrn";
}
?>
转载地址:http://ieqhp.baihongyu.com/