<?php /** * Created by PhpStorm. * User: dllo * Date: 16/8/12 * Time: 下午3:14 */ session_start(); header("Content-type:text/html;charset=utf-8"); header("Content-type: image/png"); $width = 200; $height = 100; $im = @imagecreatetruecolor($width,$height) or die('创建图像失败'); $backgroundColor = imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255)); imagefill($im,0,0,$backgroundColor); $borderColor = imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255)); imagerectangle($im,0,0,$width-1,$height-1,$borderColor); $textColor = imagecolorallocate($im,rand(50,180),rand(50,180),rand(50,180)); $fontSize = rand(14,18); $code = rand(999,9999); imagestring($im,$fontSize,rand(20,$width/2),rand($height /2 ,$height-20),$code,$textColor); $_SESSION["mycode"] = $code; imagepng($im); imagedestroy();
验证码
最新推荐文章于 2025-02-27 12:08:26 发布