function SimpleHash($str){$n = 0;// The magic happens here:// I just loop trough all letters and add the// ASCII value to a integer variable. for ($c=0; $c < strlen($str); $c++)$n += ord($str[$c]);// After we went trough all letters// we have a number that represents the// content of the stringreturn $n;}调用方法:$TestString = "www.jb51.net";print SimpleHash($TestString); // returns: 1082希望本文所述对大家的php程序设计有所帮助。