Home > Article > Backend Development > PHP verification code implements partial refresh_PHP tutorial
Generally when using verification codes, we have to implement partial refresh. This is inevitable and is also a point to improve user experience. Let’s take a look at the usage of PHP verification codes in practical applications. Friends in need can refer to it. one time.
/*
* Auth_code() is the verification code function
* @access public
* @param int $width represents the length of the verification code, the default is 80
* @param int $height represents the height of the verification code, the default is 20
* @param int $num represents the number of digits in the verification code, the default is 4
* @param int $line represents the number of lines in the verification code, the default is 4
* @param int $line represents the number of midpoints in the verification code, the default is 150
*/
The code is as follows
| Copy code
| ||||
function Auth_code($width = 80,$height = 20,$num = 4,$line = 4,$dot = 150) { $length = floor($width/$num); //floor: take the integer part length: the average length of each segment for($i=0;$i<$num;$i++) @$rand.=dechex(mt_rand(1,15)); $_SESSION['code']=$rand; //Create a new drawing board with a black background
|
The code is as follows<🎜> | Copy code<🎜> <🎜> |
Statement: The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn Previous article:PHP needs to ban some dangerous functions_PHP tutorialNext article:PHP needs to ban some dangerous functions_PHP tutorial Related articlesSee more |