首页 » Web前端 » php随机数验证码技巧_若何用PHP措辞绘制多样字符验证码

php随机数验证码技巧_若何用PHP措辞绘制多样字符验证码

访客 2024-11-10 0

扫一扫用手机浏览

文章目录 [+]

//利用PHP绘图技能,画出自己的验证码

$checkCode=\公众\"大众;

php随机数验证码技巧_若何用PHP措辞绘制多样字符验证码

for($i=0;$i<4;$i++){

php随机数验证码技巧_若何用PHP措辞绘制多样字符验证码
(图片来自网络侵删)

//dechex把一个十进制数转换成十六进制

$checkCode.=dechex(rand(1,15));

}

//存入到session

session_start();

$_SESSION['checkcode']=$checkCode;

//创建画布

$image1=imagecreatetruecolor(110,30);

//创建颜色

$white=imagecolorallocate($image1,255,255,255);

//绘制字符

imagestring($image1,rand(1,5),rand(0,80),rand(0,20),$checkCode,$white);

//画出滋扰线

//创建滋扰线随机颜色

for($i=0;$i<20;$i++){

$randomColor=imagecolorallocate($image1,rand(0,255),rand(0,255),rand(0,255));

imageline($image1,rand(0,110),rand(0,30),rand(0,110),rand(0,30),$randomColor);

}

//输出

header(\公众content-type:image/png\"大众);

imagepng($image1);

//销毁图片

imagedestroy($image1);

?>

图片形式是这样的

以上便是如何用PHP措辞绘制多样字符验证码的详细内容,更多请关注其它干系文章!

更多技巧请《转发 + 关注》哦!

标签:

相关文章

php缩表技巧_吓倒美股的是缩表而不是通胀

预期差视角的代价与局限公民币汇率的压力与韧性当心经济的二次探底风险俄乌战役的博弈剖析稳增长政策显效 A股市场可关注两大主线政策要纠...

Web前端 2024-12-12 阅读0 评论0