This article describes how to use the DZX1.5 random number function random in php source code analysis. The example shows how to use the random function in DZX1.5 to generate random strings, for more information about how to use the DZX1.5 random number function random in php source code analysis, see the following example. Share it with you for your reference. The details are as follows:
<? Php/*** @ param int $ length: Random number length * @ param int $ numeric: 0 or not 0, where 0 indicates that the random number is composed of all numbers, A non-0 random number is composed of all letters * @ 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 ). '20140901'): ($ 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 ('15', 1); echo'
'; Echo random ('15');/* End of php */
The running result is as follows:
228283270677112
SjqffsU76994qfS
I hope this article will help you with php programming.