码迷,mamicode.com
首页 > Web开发 > 详细

php基本的验证码

时间:2014-12-08 19:38:37      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:php

<?php
/*
 * Created on 2014-12-8
 *
 * Tge the templats erated file go to
 * indow - Prefer- P Code Templates
 */
 session_start();

$rand='';
/*设置字符*/
 for($i=0;$i<4;$i++){
 	$rand.=dechex(rand(1,15));
 }
 $_SESSION['check_pic']=$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);
?>

php基本的验证码

标签:php

原文地址:http://blog.csdn.net/dapeng0112/article/details/41807125

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!