这是一个PHP验证码的代码,大家帮我看一下那里出错了,显示的是乱码。

这里是captcha.php文件代码。<?phpinclude'functions.php';//muststartofcontinuesessionandsaveCAP... 这里是captcha.php文件代码。
<?php
include 'functions.php';
//must start of continue session and save CAPTCHA string in $_SESSION for
//it to be available to other requests
if (!isset($_SESSION))
{
session_start();
header('Cache-control:private');
}
//create a 65x20 pixel image
$width=65;
$height=20;
$image=imagecreate(65,20);

//fill the image background color
$bg_color=imagecolorallocate($image,0x33,0x66,0xff);
imagefilledrectangle($image,0,0,$width,$height,$bg_color);

//fetch random text
$text=random_text(5);

//determine x and y coordinates for centering text
$font=5;
$x=imagesx($image)/2-strlen($text)*imagefontwidth($font)/2;
$y=imagesy($image)/2-imagefontheight($font)/2;

//write text on image
$fg_color=imagecolorallocate($image,0xff,0xff,0xff);
imagestring($image,$font,$x,$y,$text,$fg_color);

//save the CAPTCHA string for later comparison
$_SESSION['captcha']=$text;

//output the image
header('contert-type:image/png');

imagepng($image);

imagedestroy($image);
?>

这里是functions.php文件代码。
<?php
//return a string of random text of a dexired length
function random_text($count,$rm_similar=false)
{
//create list of characters
$chars=array_flip(array_merge(range(0,9),range('A','z')));
//remove similar looking characters that might cause confusion
if ($rm_similar)
{
unset($chars[0],$chars[1],$chars[2],$chars[5],$chars[8],$chars['B'],$chars['I'],$chars['O'],$chars['Q'],$chars['S'],$chars['U'],$chars['V'],$chars['Z']);
}
//generate the string of random text
for ($i=0 , $text = ''; $i<$count; $i++)
{
$text .= array_rand($chars);
}
return $next;
}
?>
展开
 我来答
uanguei
2009-09-19 · TA获得超过268个赞
知道答主
回答量:51
采纳率:0%
帮助的人:0
展开全部
header('contert-type:image/png');
应该是
header('content-type:image/png');
拼写错误
AiPPT
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图... 点击进入详情页
本回答由AiPPT提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式