php-验证码

2021-11-27 169 0

//封装为函数调用
<?php
function show($fontsize){
    //创建画布资源
	$im=imagecreatetruecolor(200, 100);
    //准备颜料
	$gray=imagecolorallocate($im, 100, 100, 100);
	$black=imagecolorallocate($im,0, 0, 0);
    //画布背景
	imagefill($im, 0, 0, $gray);
    //在画布上写字或画图
	$strarr=@array_merge(range(0,9),range(a,z),range(A,Z));
	shuffle($strarr);
	$str=join(array_slice($strarr,0,4));
	 $file="msyh.ttf";
	 imagettftext($im, $fontsize, 0, 50,50, $black, $file, $str);
    //输出
    header("content-type:image/png");
    imagepng($im);
    //释放资源
    imagedestroy($im);
}
show(15);
?>

相关文章

Linux-如何升级php的版本
WordPress-更换链接格式之后报404错误
Linux-使用Remi源安装最新版PHP
PHP-WordPress连接数据库失败问题
php-网络安全实验室脚本关快速口算题
php-从网页中提取关键字

发布评论