欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

php 验证码功能 下面的代码是完全ok 有大用

shiping1 的头像
<?php
session_start();
Header("Content-type: image/gif");
//这里是更改图像的宽高
$im = imagecreate(400,30);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
$num = intval(sprintf("%4d", mt_rand(1, 9999)));

ImageTTFText($im, 20, 0, 10, 20, $white, "./simhei.ttf", $num);
$_SESSION['check_code'] = $num;
//setcookie('num',$num);
ImageGif($im);

?>

还用到 同目录下  simhei.ttf 文件,
见 附件  txt 文件 下载  下来后文件名为 simhei.ttf 即可
附件大小
Plain text icon simhei.ttf694 个字节
普通分类: