for($i=0;$i<4;$i++){ $rand.=dechex(rand(1,15));}
//设置图像大小
$im=imagecreatetruecolor(100,30);
//设置颜色
$bg=imagecolorallocate($im,0,0,0);
$te=imagecolorallocate($im,255,255,255);
//把字符串写在图像上面
imagestring($im,rand(3,6),rand(3,70),rand(0,16),$rand,$te);
//输出图像
header("Content-type: image/jpeg");
imagejpeg($im);
?>为何图片显示一个红叉。。
gd库已经打开
//设置图像大小
$im=imagecreatetruecolor(100,30);
//设置颜色
$bg=imagecolorallocate($im,0,0,0);
$te=imagecolorallocate($im,255,255,255);
//把字符串写在图像上面
imagestring($im,rand(3,6),rand(3,70),rand(0,16),$rand,$te);
//输出图像
header("Content-type: image/jpeg");
imagejpeg($im);
?>为何图片显示一个红叉。。
gd库已经打开
error_reporting(E_ALL ^ E_NOTICE);开头加上这一行,,或者先预定义变量再使用
Notice: Undefined variable: rand在文件头上加上 $rand = '';就可以了
就能看到原因
$rand='';
for($i=0;$i<4;$i++){ $rand.=dechex(rand(1,15));}//设置图像大小
$_SESSION[check]=$rand;
$im=imagecreatetruecolor(100,30);
//设置颜色
$bg=imagecolorallocate($im,0,0,0);
$te=imagecolorallocate($im,255,255,255);
//把字符串写在图像上面
imagestring($im,rand(3,6),rand(3,70),rand(0,16),$rand,$te);
//输出图像
header("Content-type: image/jpeg");
imagejpeg($im);
这样加入session又不能显示了,何解。。