SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    a function's meaning

    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/2...gle-page-rank/

    but the code for me is hard to understand.


    Code:
        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.

  2. #2
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    anyone helps?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •