>  기사  >  백엔드 개발  >  php根本的验证码

php根本的验证码

WBOY
WBOY원래의
2016-06-13 12:11:10885검색

php基本的验证码

<?php /* * Created on 2014-12-8 * * Tge the templats erated file go to * indow - Prefer- P Code Templates */ session_start();$rand=&#39;&#39;;/*设置字符*/ for($i=0;$i<4;$i++){ 	$rand.=dechex(rand(1,15)); } $_SESSION[&#39;check_pic&#39;]=$rand; /*设置画布大小*/ $img=imagecreatetruecolor(100,30);/*设置颜色*/$bg=imagecolorallocate($img,0,0,0);$te=imagecolorallocate($img,255,255,255);/*将字符串写入图像*/imagestring($img,rand(1,6),rand(1,70),rand(1,10),$rand,$te);/*图片,字体,x轴距离,y轴距离,写入的文字,写入的颜色*//*输出图像*/header("Content-type: image/jpeg");imagejpeg($img);?>

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.