/**
* Generate unique identification numbers based on PHP various types of variables
* @param mixed $mix variables
* @return String
*/
Function to_guid_string ($mix) { if (Is_object ($mix)) { return spl_object_hash ($mix);//spl_object_hash - Returns the hash id } elseif (Is_resource ($mix)) of the specified object {//is_resource - detects if a variable is a resource type $mix = get_resource_ Type ($mix) . strval ($mix);//get_resource_type - return resource (Resource) types //strval - Get the string value of a variable } else { $mix = serialize ($mix);//serialize - produces a representation of a stored value//$name = "Jin Sha Wan" serialize series For s:12: "Jin Sha Harbor"; } return md5 ($mix);//md5 - computes the string MD5 hash value}class student{ public $name = ' Jin Sha harbour ';} $stu =new student ();//Object $fp = fopen ("D:/wamP/counter.txt "," w ");//Resources $name=" Jin Sha Harbor ";//String echo to_guid_string ($stu);echo " <br/> "; echo to_ Guid_string ($fp);echo "<br/>"; echo to_guid_string ($name);
The result of the operation is:
00000000411ac22f0000000001dac5a4
7c8337ca66fc7eb79d20461b44630219
99a71c3a715645befef323c9a805f662
This article is from the "11400485" blog, please be sure to keep this source http://11410485.blog.51cto.com/11400485/1833446
thinkphp Source Learning to_guid_string function generates a unique identification number based on PHP various types of variables