php 生成中文验证码程序
今天无意中想起写验证码数字加汉字,下面是代码比较容易没什么好说
先来看看效果图吧.
还不错吧?
Header("Content-type: image/PNG");//生成图片的类型
$str = "的一是在了不和有大这主中人蚕亿矩";//随便回的你可以自己增加
$Width = 240;//图片高度
$imgHeight = 40;//图片宽度
$C_img = imagecreate($Width,$imgHeight);
$bgColor = ImageColorAllocate($C_img,255,255,255);
$f_font = "heiti.ttf";//这里可以选择其它的字体
$white=imagecolorallocate($C_img,234,185,95);
imagearc($C_img, 150, 8, 20, 20, 75, 170, $white);
imagearc($C_img, 180, 7,50, 30, 75, 175, $white);
imageline($C_img,20,20,180,30,$white);
imageline($C_img,20,18,170,50,$white);
imageline($C_img,25,50,80,50,$white);
$noise_num = 800;//杂点的数据
$line_num = 20;//线条的数量
imagecolorallocate($C_img,0xff,0xff,0xff);
$rectangle_color=imagecolorallocate($C_img,0xAA,0xAA,0xAA);
$noise_color=imagecolorallocate($C_img,0x00,0x00,0x00);
$font_color=imagecolorallocate($C_img,0x00,0x00,0x00);
$line_color=imagecolorallocate($C_img,0x00,0x00,0x00);
for($i=0;$i
imagesetpixel($C_img,mt_rand(0,$Width),mt_rand(0,$imgHeight),$noise_color);
}
for($i=0;$i
imageline($C_img,mt_rand(0,$Width),mt_rand(0,$imgHeight),mt_rand(0,$Width),mt_rand(0,$imgHeight),$line_color);
}
$randnum=rand(0,strlen($str)-4);
if($randnum%2)$randnum+=1;
$str = substr($str,$randnum,8);
$str = iconv("GB2312","UTF-8",$str).rand(0,1000);//转换编码
ImageTTFText($C_img, 20, 0, 16, 30, $font_color, $f_font, $str);
ImagePNG($C_img);
ImageDestroy($C_img);
?>
注明:转载请说明原处www.111cn.net

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Methods to open img files include using virtual optical drive software, using compression software, and using special tools. Detailed introduction: 1. Use virtual optical drive software to open, download and install a virtual optical drive software, right-click the img file, select "Open with" or "Associated Program", select the installed virtual optical drive software in the pop-up dialog box, virtual The optical drive software will automatically load the img file and use it as a disc image in the virtual optical drive. Double-click the disc icon in the virtual optical drive to open the img file and access its contents, etc.

During the development or learning process of using Golang, we may encounter the error message of undefined:rand.Seed. This error usually occurs when you need to use a random number generator, because in Golang you need to set a random number seed before you can use the function in the rand package. This article will explain how to resolve this error. 1. Introduce the math/rand package. First, we need to introduce the math/rand package into the code. exist

How to open the img file: 1. Confirm the img file path; 2. Use the img file opener; 3. Select the opening method; 4. View the picture; 5. Save the picture. The img file is a commonly used image file format, usually used to store picture data.

img is a file compression format, mainly used to create image files of floppy disks. It can be used to compress the contents of an entire floppy disk or an entire CD; files with the extension ".IMG" are created using this file format. ; The img file includes 3 basic nodes, namely "Ehfa_HeaderTag", "Ehfa_File" and "Ehfa_Entry".

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Synchronizing random number generation in Go concurrent programming: Use a mutex (sync.Mutex) to control access to the rand.Rand random number generator. Each goroutine acquires the mutex lock before generating random numbers and releases the mutex lock after generating it. This ensures that only one goroutine can access the random number generator at a time, eliminating data races.

The rand() function uses the same initial seeds on each call. The default initial seed is obtained from the operating system's time, but it only has microsecond accuracy. That is, within a very short period of time, many rand() function calls will use the same initial seed, resulting in the same random number generation. So, how to solve this problem?

U disk is one of the frequently used storage devices. There will also be some minor problems during use. For example: the U disk cannot be read. How to solve it? Put it away! Can’t read the USB flash drive? 4 steps to teach you how to solve the problem easily. After the USB flash drive has been inserted into the computer, click the Start menu, select Control Panel and put it away! Can’t read the USB flash drive? 4 steps to teach you to easily solve the problem. Find and double-click Device Manager in Control Panel. Keep it! Can’t read the USB flash drive? 4 steps to teach you how to easily solve the problem: Find the Universal Serial Bus controller on the main interface of the Device Manager and put it away! Can’t read the USB flash drive? 4 steps to teach you how to easily find the USB mass storage device, select it, right-click, find Uninstall and put it away! Can’t read the USB flash drive? 4 steps to teach you how to solve the problem easily. Welcome to leave a message for discussion!
