ord(PHP4,PHP5,PHP7)ord--返回字符的ASCII值ord--返回字符的ASCII码值说明intord(string$string)//返回thefirstcharacterofstring.//返回字符串string第一个字符的ASCII码值。//这个函数是chr()的补充函数。//这个函数是chr()的补充函数。参数string一个字符。一个人物。返回值以整数形式返回ASCII值。返回整数的ASCII值。示例=128){//否则0xxxxxxxif($code<224){$bytesnumber=2;}//110xxxxxelseif($code<240){$bytesnumber=3;}//1110xxxxelseif($code<248){$bytesnumber=4;}//11110xxx$codetemp=$code-192-($bytesnumber>2?32:0)-($bytesnumber>3?16:0);对于($i=2;$i<=$bytesnumber;$i++){$偏移量++;$code2=ord(substr($string,$offset,1))-128;//10xxxxxx$codetemp=$codetemp*64+$code2;}$code=$codetemp;}$抵消+=1;如果($offset>=strlen($string)){$offset=-1;}return$code;}$text="中国?";$offset=0;while($offset>=0){//0:20013//3:22269//6:128516echo$offset.“:”。ordutf8($文本,$offset)。PHP_EOL;}functionuniord($u){$k=mb_convert_encoding($u,'UCS-2LE','UTF-8');$k1=ord(substr($k,0,1));$k2=ord(substr($k,1,1));返回$k2*256+$k1;}echouniord("中")。PHP_EOL;//20013echouniord("国").PHP_EOL;//22269//errorechouniord('?')。PHP_EOL;//63见http://php.net/manual/en/func...版权所有
