PHP生成4位可能5位的字母和数字组合验证码
PHP生成4位或者5位的字母和数字组合验证码
<?php $img = imagecreatetruecolor(100, 40);//创建一个100*40的画布$black = imagecolorallocate($img, 0x00, 0x00, 0x00);//定义黑色$green = imagecolorallocate($img, 0x00, 0xFF, 0x00);//定义绿色$white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);//定义白色imagefill($img,0,0,$white); //使用白色填充画布//生成数字和字母的4位或者5位的随机验证码$str = 'abcdefghijkmnpqrstuvwxyz1234567890';$arr = str_split($str);shuffle($arr);$code = '';$arr = implode($arr);$code = substr($arr,rand(0,5),rand(4,5));imagestring($img, 5, 20, 15, $code, $black);//将验证码绘制到画布上//加入噪点干扰for($i=0;$i<50;$i++) { imagesetpixel($img, rand(0, 100) , rand(0, 100) , $black); imagesetpixel($img, rand(0, 100) , rand(0, 100) , $green);}//加入图像干扰for($i=0;$i<20;$i++){ imageline($img,rand(0, 100), rand(0, 100), rand(0, 100),rand(0, 100), $green);}//输出验证码header("content-type: image/png");imagepng($img);imagedestroy($img);
版权声明:本文为博主原创文章,未经博主允许不得转载。

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

AI Hentai Generator
Generate AI Hentai for free.

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".

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!

How to change the img src attribute in jquery: 1. Use the attr() attribute, the syntax "$("img").attr("src","The address of the image file")"; 2. Use the prop() method, the syntax " $("img").prop("src","The address of the image file")".
