验证码问题 为何我在本地测试验证码显示正常,到服务器上验证码就不显示了呢。只显示一个红叉号 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?session_start();//生成验证码图片Header("Content-type: image/PNG");$im = imagecreate(44,18);$back = ImageColorAllocate($im, 245,245,245);imagefill($im,0,0,$back); //背景srand((double)microtime()*1000000);//生成4位数字for($i=0;$i<4;$i++){$font = ImageColorAllocate($im, rand(100,255),rand(0,100),rand(100,255));$authnum=rand(0,9);$vcodes.=$authnum;imagestring($im, 5, 2+$i*10, 1, $authnum, $font);}for($i=0;$i<100;$i++) //加入干扰象素{ $randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);} setcookie("yanz","$vcodes");ImagePNG($im);ImageDestroy($im);$_SESSION['VCODE'] = $vcodes;?> 在第一行加上试试ob_end_clean(); 求助!! 我想做个小偷程序,哪位朋友可以帮帮我 网站返回值写入cookies问题 想做个网站,让大家建议下,选择哪个开源程序好? dede文章调用前六篇文章和后六篇文章 紧急求教 我的这个代码错在哪了 php的DES CBC消息验证方法 这段时间做程序的小感悟! 关于接口的问题 linux 中php-fpm的问题 PHP和数据库的一些问题 安装shopex 第二步出现乱码问题 腾讯算法题
//生成验证码图片
Header("Content-type: image/PNG");
$im = imagecreate(44,18);
$back = ImageColorAllocate($im, 245,245,245);
imagefill($im,0,0,$back); //背景
srand((double)microtime()*1000000);
//生成4位数字
for($i=0;$i<4;$i++){
$font = ImageColorAllocate($im, rand(100,255),rand(0,100),rand(100,255));
$authnum=rand(0,9);
$vcodes.=$authnum;
imagestring($im, 5, 2+$i*10, 1, $authnum, $font);
}for($i=0;$i<100;$i++) //加入干扰象素
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
}
setcookie("yanz","$vcodes");
ImagePNG($im);
ImageDestroy($im);$_SESSION['VCODE'] = $vcodes;?>
ob_end_clean();