超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<number_formatparse_str>
Last updated: Fri, 22 Jun 2007

ord

(PHP 3, PHP 4 , PHP 5)

ord -- Return ASCII value of character

Description

int ord ( string string)

Returns the ASCII value of the first character of string. This function complements chr().

例子 1. ord() example

<?php
$str
= "\n";
if (
ord($str) == 10) {
   echo
"The first character of \$str is a line feed.\n";
}
?>

You can find an ASCII-table over here: http://www.asciitable.com.

See also chr().




add a note add a note User Contributed Notes
ord
theanimus at btconnect dot com
07-Jul-2001 02:01
[Ed: bindec() does this for you... it only doesn't get the sign-bit. Your solution will result in a float with the sign is set!
http://www.php.net/bindec
--jeroen ]

Erm this one took me a while to work out, in the end a friend told me, if ur working out the value of an 32bit integer ($data) then this is 4 u ;-)

$num=ord($data[0])+(ord($data[1])<<8)+(ord($data[2])<<16)+(ord($data[3])<<24);
if ($num>=4294967294){
$num-=4294967296;
}

<number_formatparse_str>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22