欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

簡單的php 驗(yàn)證圖片生成函數(shù)

 更新時(shí)間:2009年05月21日 02:34:22   作者:  
本函數(shù)可以生成簡單的驗(yàn)證圖片,用于輸入的驗(yàn)證。
復(fù)制代碼 代碼如下:

<?php
function yzm($name,$width,$height){
Header("Content-type: image/PNG");
srand((double)microtime()*1000000);//播下一個(gè)生成隨機(jī)數(shù)字的種子,以方便下面隨機(jī)數(shù)生成的使用
session_start();//將隨機(jī)數(shù)存入session中
$_SESSION[$name]="";
$im = imagecreate($width,$height); //制定圖片背景大小
$black = ImageColorAllocate($im, 0,0,0); //設(shè)定三種顏色
$white = ImageColorAllocate($im, 255,255,255);
$gray = ImageColorAllocate($im, 200,200,200);
imagefill($im,0,0,$gray); //采用區(qū)域填充法,設(shè)定(0,0)
while(($authnum=rand()%100000)<10000);
$_SESSION[$name]=$authnum;
imagestring($im, 5, 10, 3, $authnum, $black);
for($i=0;$i<200;$i++)//加入干擾象素
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
}
ImagePNG($im);
ImageDestroy($im);
}?>

使用方法,將其建立一個(gè)php文件入yzm.php,調(diào)用<img src="aaa.php?w=100&h=20&name=aaa">
將參數(shù)調(diào)用到本函數(shù)中即可。

相關(guān)文章

最新評(píng)論