search
Homephp教程PHP源码php 生成中文验证码程序

<script>ec(2);</script>

今天无意中想起写验证码数字加汉字,下面是代码比较容易没什么好说

先来看看效果图吧.

还不错吧?

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

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
img文件怎么打开img文件怎么打开Sep 18, 2023 am 09:40 AM

打开img文件的方法有使用虚拟光驱软件打开、使用压缩软件打开和使用专用工具打开。详细介绍:1、使用虚拟光驱软件打开,下载并安装一个虚拟光驱软件,右键单击img文件,选择“打开方式”或“关联程序”,在弹出的对话框中选择安装的虚拟光驱软件,虚拟光驱软件会自动加载img文件,并将其作为虚拟光驱中的光盘映像,双击虚拟光驱中的光盘图标,即可打开img文件并访问其中的内容等等。

如何解决 golang 中的 “undefined: rand.Seed” 错误?如何解决 golang 中的 “undefined: rand.Seed” 错误?Jun 25, 2023 am 08:34 AM

在使用Golang进行开发或学习过程中,我们可能会遇到undefined:rand.Seed的错误提示。这个错误通常会在需要使用随机数生成器时出现,因为在Golang中需要先设置一个随机数种子,才能使用rand包中的函数。本篇文章将介绍如何解决这种错误。1.引入math/rand包首先,我们需要在代码中引入math/rand包。在

img文件如何打开img文件如何打开Jul 06, 2023 pm 04:17 PM

img文件打开的方式:1、确认img文件路径;2、使用img文件打开器;3、选择打开方式;4、查看图片;5、保存图片。img文件是一种常用的图像文件格式,通常用于存储图片数据。

img是什么格式img是什么格式Mar 17, 2023 am 10:33 AM

img是一种文件压缩格式,主要是为了创建软盘的镜像文件,它可以用来压缩整个软盘或整片光盘的内容;使用“.IMG”这个扩展名的文件就是利用这种文件格式来创建的;img文件包括3个基本节点,分别是“Ehfa_HeaderTag”、“Ehfa_File”和“Ehfa_Entry”。

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决Jun 13, 2016 am 10:23 AM

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

如何在 Golang 并行处理中同步随机数生成?如何在 Golang 并行处理中同步随机数生成?Jun 03, 2024 pm 02:53 PM

在Go并发编程中同步随机数生成:使用互斥锁(sync.Mutex)控制对rand.Rand随机数生成器的访问。每个goroutine在生成随机数前获取互斥锁,并在生成后释放互斥锁。这确保了同一时间只有一个goroutine可以访问随机数生成器,消除了数据争用。

php rand函数生成相同随机数怎么解决php rand函数生成相同随机数怎么解决Mar 23, 2023 am 09:17 AM

rand()函数在每次调用时使用相同的初始种子(seeds)。预设的初始种子是从操作系统的时间获得的,但是它只有微秒级的精度。也就是说,在极短的时间内,许多rand()函数调用都将使用相同的初始种子,从而导致相同的随机数生成。那么,如何解决这个问题呢?

u盘pe读不出imgu盘pe读不出imgMar 19, 2024 pm 12:07 PM

U盘是经常用到的储存设备之一,那在使用过程中也会出现一些小问题,比如:U盘读不出,那该怎么解决呢?收好!u盘读不出来?4步教你轻松解决在U盘已经插到电脑的基础上点击开始菜单,选中控制面板收好!u盘读不出来?4步教你轻松解决在控制面板里找到并双击设备管理器。收好!u盘读不出来?4步教你轻松解决在设备管理器的主界面找到通用串行总线控制器收好!u盘读不出来?4步教你轻松解决找到usb大容量存储设备,选中它点击右键找到卸载收好!u盘读不出来?4步教你轻松解决欢迎留言讨论哟!

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools