imagettftext($img, 25, mt_rand(-15,15), $x_start, 50/2, $fontcolor, "C:/Windows/Fonts/Verdana.TTF", $key);
$img-----------画布
25-----------字体的尺寸。
mt_rand(-15,15)----------角度制表示的角度,0 度为从左向右读的文本。更高数值表示逆时针旋转。例如 90 度表示从下向上读的文本。(就是字体角度的问题,)
$x_start----------通俗易懂的讲就是字符的X轴位置
50/2----------字符的高度
$fontcolor----------字符颜色
"C:/Windows/Fonts/Verdana.TTF"----------字符的字体样式路径
$key-----------遍历出后的字符
效果:
以上内容是本文给大家介绍的最新最全PHP生成制作验证码代码详解(推荐)的全部叙述,希望对大家有所帮助!
... < $this->codeLen; $i++) {
$this->code .= $this->charset[mt_rand(0, $_len)];
}
}3.4生成验证码背景色.//生成背景
private function creat
mt_rand() 比rand() 快四倍,很多老的 libc 的随机数发生器具有一些不确定和未知的特性而且很慢。PHP 的 rand() 函数默认使用 libc 随机数发生器。mt_rand() 函数是非正式用来替换它的。PHP函数rand和mt_rand mt_rand() 比rand()
...=4;
for($i=0;$i
...>//创建随机数for($i=0;$i
...olorAllocate($im, 238,238,238); //设置背景颜色
$values = array(
mt_rand(0,$pw), mt_rand(0,$ph),
mt_rand(0,$pw), mt_rand(0,$ph),
mt_rand(0,$pw),
...34567890"; $image=imagecreate(50,25);imagecolorallocate($image,mt_rand(0,125),mt_rand(0,125),mt_rand(0,125));$color = imagecolorallocate($image,mt_
...>//创建随机数for($i=0;$i
... //0点 $color = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)); imagefilledrectangle($
... //创建背景色
$bg = imagecolorallocate($this->image, mt_rand(220, 255), mt_rand(220, 255), mt_rand(220, 255));
//填充背景色
i
...布并设置大小 x轴150 y轴50 6 7 $bgcolor = imagecolorallocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));//分配背景颜色 8 imagefill($img, 0, 0, $bgcolo