php 实现验证码制造
php 实现验证码制作
先给看下 大致的效果
那么接下来的就直接贴代码吧
<span style="color: #000000;">php </span><span style="color: #800080;">$image</span> = imagecreatetruecolor(100, 30); <span style="color: #008000;">//</span><span style="color: #008000;">创建画布</span> <span style="color: #800080;">$imagecolor</span> = imagecolorallocate(<span style="color: #800080;">$image</span>, 255, 255, 255); <span style="color: #008000;">//</span><span style="color: #008000;">背景色</span><span style="color: #000000;"> imagefill(</span><span style="color: #800080;">$image</span>, 0, 0, <span style="color: #800080;">$imagecolor</span>); <span style="color: #008000;">//</span><span style="color: #008000;">填充背景色</span> <span style="color: #0000ff;">for</span>(<span style="color: #800080;">$i</span>=0;<span style="color: #800080;">$i</span>$i++ ){ <span style="color: #008000;">//</span><span style="color: #008000;">循环4位数</span> <span style="color: #800080;">$fontsize</span> = 6<span style="color: #000000;">; </span><span style="color: #800080;">$fontcolor</span> = imagecolorallocate(<span style="color: #800080;">$image</span>, <span style="color: #008080;">rand</span>(0, 200), <span style="color: #008080;">rand</span>(0, 200), <span style="color: #008080;">rand</span>(0, 200<span style="color: #000000;">)); </span><span style="color: #800080;">$fontcontent</span> = <span style="color: #008080;">rand</span>(0, 9<span style="color: #000000;">); </span><span style="color: #800080;">$x</span> = <span style="color: #800080;">$i</span>*100/4 + <span style="color: #008080;">rand</span>(5, 15<span style="color: #000000;">); </span><span style="color: #800080;">$y</span> = <span style="color: #008080;">rand</span>(5, 10<span style="color: #000000;">); imagestring(</span><span style="color: #800080;">$image</span>, <span style="color: #800080;">$fontsize</span>, <span style="color: #800080;">$x</span>, <span style="color: #800080;">$y</span>, <span style="color: #800080;">$fontcontent</span>, <span style="color: #800080;">$fontcolor</span><span style="color: #000000;">); } </span><span style="color: #0000ff;">for</span>(<span style="color: #800080;">$i</span>=0;<span style="color: #800080;">$i</span>$i++ ){ <span style="color: #008000;">//</span><span style="color: #008000;">循环 添加干扰点</span> <span style="color: #800080;">$pointcolor</span> = imagecolorallocate(<span style="color: #800080;">$image</span>, <span style="color: #008080;">rand</span>(50, 200), <span style="color: #008080;">rand</span>(50, 200), <span style="color: #008080;">rand</span>(50, 200<span style="color: #000000;">)); </span><span style="color: #800080;">$x</span> = <span style="color: #008080;">rand</span>(1, 99<span style="color: #000000;">); </span><span style="color: #800080;">$y</span> = <span style="color: #008080;">rand</span>(1, 29<span style="color: #000000;">); imagesetpixel(</span><span style="color: #800080;">$image</span>, <span style="color: #800080;">$x</span>, <span style="color: #800080;">$y</span>, <span style="color: #800080;">$pointcolor</span><span style="color: #000000;">); } </span><span style="color: #0000ff;">for</span>(<span style="color: #800080;">$i</span>=0;<span style="color: #800080;">$i</span>$i++){ <span style="color: #008000;">//</span><span style="color: #008000;">循环 添加干扰线 </span> <span style="color: #800080;">$linecolor</span> = imagecolorallocate(<span style="color: #800080;">$image</span>, <span style="color: #008080;">rand</span>(100, 250), <span style="color: #008080;">rand</span>(100, 250), <span style="color: #008080;">rand</span>(100, 250<span style="color: #000000;">)); </span><span style="color: #800080;">$x1</span> = <span style="color: #008080;">rand</span>(1, 25<span style="color: #000000;">); </span><span style="color: #800080;">$x2</span> = <span style="color: #008080;">rand</span>(50, 75<span style="color: #000000;">); </span><span style="color: #800080;">$y1</span> = <span style="color: #008080;">rand</span>(1, 15<span style="color: #000000;">); </span><span style="color: #800080;">$y2</span> = <span style="color: #008080;">rand</span>(15, 25<span style="color: #000000;">); imageline(</span><span style="color: #800080;">$image</span>, <span style="color: #800080;">$x1</span>, <span style="color: #800080;">$y1</span>, <span style="color: #800080;">$x2</span>, <span style="color: #800080;">$y2</span>, <span style="color: #800080;">$linecolor</span><span style="color: #000000;">); } </span><span style="color: #008080;">header</span>("content-type:image/png"<span style="color: #000000;">); imagepng(</span><span style="color: #800080;">$image</span><span style="color: #000000;">); imagedestroy(</span><span style="color: #800080;">$image</span><span style="color: #000000;">);</span>?>

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











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

This article will introduce seven ways to get high-quality output using the free BingImageCreator. BingImageCreator (now known as ImageCreator for Microsoft Designer) is one of the great online artificial intelligence art generators. It generates highly realistic visual effects based on user prompts. The more specific, clear, and creative your prompts are, the better the results will be. BingImageCreator has made significant progress in creating high-quality images. It now uses Dall-E3 training mode, showing a higher level of detail and realism. However, its ability to consistently produce HD results depends on several factors, including fast

How to delete images on Xiaomi mobile phones? You can delete images on Xiaomi mobile phones, but most users don’t know how to delete images. Next is the tutorial on how to delete images on Xiaomi mobile phones brought by the editor. Interested users can come and join us. Let's see! How to delete images on Xiaomi mobile phone 1. First open the [Album] function in Xiaomi mobile phone; 2. Then check the unnecessary pictures and click the [Delete] button in the lower right corner; 3. Then click [Album] at the top to enter the special area , select [Recycle Bin]; 4. Then directly click [Empty Recycle Bin] as shown in the figure below; 5. Finally, directly click [Permanent Delete] to complete.

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?

LINUX is an open source operating system. Its flexibility and customizability make it the first choice of many developers and system administrators. In the LINUX system, image processing is a very important task, and Imagemagick and Image are Two very popular image processing tools, this article will introduce you to how to install Imagemagick and Image in Centos system, and provide detailed installation tutorials. Imagemagic installation Centos tutorial Imagemagick is a powerful image processing toolset, which can perform various image operations under the command line. The following are the steps to install Imagemagick on Centos system: 1

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.

Coins and banknotes are considered legal tender in Australia, but their worth can vary from the dollar value they are assigned if they are out of the ordinary.

Ethereum, the world's second-biggest cryptocurrency has been consolidating in a tight range following the breaking of a bearish rising wedge price action pattern on a daily time frame.
