PHP source code Analysis of DZX1.5 random number function, Dzx1.5random
The example of PHP source code Analysis of the DZX1.5 random number function. Share to everyone for your reference. Specific as follows:
<?php/** * @param int $length: Random number length * @param int $numeric: 0 or not 0, where 0 means the random number consists of a full number, not 0 means that the random number consists of a full letter * @return string: Returns the generated random Number */function random ($length, $numeric = 0) { $seed = Base_convert (MD5 (Microtime (). $_server[' Document_root ']), 16, $ Numeric? 10:35); $seed = $numeric? (Str_replace (' 0 ', ', $seed). ' 012340567890 '): ($seed. ' ZZ '. Strtoupper ($seed)); $hash = "; $max = strlen ($seed)-1; for ($i = 0; $i < $length; $i + +) { $hash. = $seed {mt_rand (0, $max)}; } return $hash;} echo Random (' 1 ', echo ')
'; Echo random (' ");/*end of php*/
The results of the operation are as follows:
228283270677112
Sjqffsu76994qfs
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1018521.html www.bkjia.com true http://www.bkjia.com/PHPjc/1018521.html techarticle PHP Source Code Analysis of the random use of the DZX1.5 function, dzx1.5random The example of the PHP source code Analysis DZX1.5 Random number function of the arbitrary usage. Share to everyone for your reference. Specific as ...