|
|
 |
ord (PHP 3, PHP 4 , PHP 5) ord -- Return ASCII value of character Descriptionint 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().
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;
}
| |