This article is for you to introduce in detail the PHP method of giving birth to random strings, with a certain reference value, interested in small partners can refer to
The example of this article for everyone to share the PHP produced random strings of the specific code for your reference, the specific content as follows
function generaterandomstring ($length = ten) { $characters = ' 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '; $randomString = "; for ($i = 0; $i < $length; $i + +) { $randomString. = $characters [rand (0, strlen ($characters)-1)]; } return $randomString; }echo generaterandomstring (20);/** * Randomly generated string * @param int $length * @return null|string */private static function Getrandc Har ($length = 8) { $str = null; $strPol = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz"; $max = strlen ($strPol)-1; for ($i =0; $i < $length; $i + +) { $str. = $strPol [rand (0, $max)];//rand ($min, $max) generates a random integer between min and Max two numbers } return $str;}