<?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"; } |