i have read over the basic knowledge of php, but still new to it. to improve the skill. i searched some examples to practice it.today,i found one.
http://www.brightyoursite.com/blog/2010/06/01/use-php-to-get-google-page-rank/
but the code for me is hard to understand.
function StrToNum($Str, $Check, $Magic) {
$Int32Unit = 4294967296;
$length = strlen($Str);
for ($i = 0; $i < $length; $i++) {
$Check *= $Magic;
if ($Check >= $Int32Unit) {
$Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
//if the check less than -2^31
$Check = ($Check < -2147483648)? ($Check + $Int32Unit) : $Check;
}
$Check += ord($Str{$i});
}
return $Check;
}
i don’t understand it well. expect someon can help me?
1, what’s the use and meaning of this line $Int32Unit = 4294967296;
2,what’s the for loop do? what’s the use of this function.