验证码的问题----请大家帮帮忙,先谢谢,以下是我的表单验证码的php文件。
<?phpfor($i=0;$i<4;$i++){
$rand .= dechex(rand(1,15));
}echo $rand;$im = imagecreatetruecolor(100,30); //创建图像$text_color = imagecolorallocate($im, 233, 14, 91);?>有两个问题---1》echo $rand;结果正常,但有提示变量未定义。去掉赋值运算符的"."之后"$rand = dechex(rand(1,15));"提示没有了。2》函数无法创建图像 $im = imagecreatetruecolor(100,30); php5.3.4--apache2.2.17运行正常,php.ini已开起gd2库,gd2版本(bundled (2.0.34 compatible) )
<?phpfor($i=0;$i<4;$i++){
$rand .= dechex(rand(1,15));
}echo $rand;$im = imagecreatetruecolor(100,30); //创建图像$text_color = imagecolorallocate($im, 233, 14, 91);?>有两个问题---1》echo $rand;结果正常,但有提示变量未定义。去掉赋值运算符的"."之后"$rand = dechex(rand(1,15));"提示没有了。2》函数无法创建图像 $im = imagecreatetruecolor(100,30); php5.3.4--apache2.2.17运行正常,php.ini已开起gd2库,gd2版本(bundled (2.0.34 compatible) )
header("Content-Type:image/gif");
imagegif($im);
imagedestroy($im)
header("Content-Type:image/gif");
imagegif($im);
imagedestroy($im)我分别:
echo $im = imagecreatetruecolor(100,30); 输出 Resource id #2
或
echo $text_color = imagecolorallocate($im, 233, 14, 91); 输出 15273563 就是无法创建图像
以下我调试成功:
<?PHP
$img=imagecreatetruecolor(200,200);
$col=imagecolorallocate($img,255,0,0);
header("Content-Type:image/gif");
imagegif($img);
imagedestroy($img);
?>
这段代码之前不要有任何HTML输出