Joke Collection Website - Public benefit messages - How does php use random function rand () to generate a digital verification code?
How does php use random function rand () to generate a digital verification code?
$code= "";
// canvas
$ image = imagecreate true color (8,25);
imagefill($image, , , imagecolorallocate($image, 255, 255, 255));
for($i=; $i< 4; $i++){
$rand_color=imagecolorallocate($image, rand(,155), rand(,155), rand(,155));
$code_tmp=dechex(rand(1,15));
$code.=$code_tmp;
imagestring($image, rand(4,5), rand($i*2,$i*2+2-6), rand(,13),$code_tmp , $rand_color);
// interference line
image line ($ image, rand ($ I * 2, $ I * 2+2), rand (,25), rand ($ I * 2, $ I * 2+2), rand (,25).
imageline($image, rand($i*2,$i*2+2), rand(,25), rand($i*2,$i*2+2), rand(,25), $rand_color);
}
// Save
session_start ();
$_SESSION['yzm']=$code;
session_write_close();
header("content-type:image/png");
imagepng($image);
imagedestroy($image);
- Previous article:How to handle wing payment?
- Next article:Love between light and night
- Related articles
- How should a girl who just got off work reply?
- Where can I find the invitation code for Dr. Ping An to stay in the mall?
- Will all major hospitals in Shanghai conduct nucleic acid tests on all employees on the 21st?
- How to set the screen reminder for Samsung note 10?
- Short message about the safety of primary school students in my heart
- Q: Congratulations on the short message of college entrance examination candidates, thank you!
- Save it. Text me to introduce others.
- What factory in Funing is recruiting women?
- Girlfriend cheated, how to recover?
- To be fair, do you think Liu Xin really knew he was wrong?