不显示PHP图像验证代码

不显示PHP图像验证代码,php,Php,下面是我的老师给出的checks.php: <?php session_start(); header("content-type:image/png"); $image_width=70; $image_height=18; srand(microtime()*100000); for($i=0;$i<4;$i++){ $new_number.=dechex(rand(0,15)); } $_SESSION[check_checks]=$new_number; $num_i

下面是我的老师给出的checks.php:

<?php
session_start();
header("content-type:image/png");
$image_width=70;
$image_height=18;
srand(microtime()*100000);
for($i=0;$i<4;$i++){
   $new_number.=dechex(rand(0,15));
}
$_SESSION[check_checks]=$new_number;

$num_image=imagecreate($image_width,$image_height);
imagecolorallocate($num_image,255,255,255);
for($i=0;$i<strlen($_SESSION[check_checks]);$i++){
   $font=mt_rand(3,5);
   $x=mt_rand(1,8)+$image_width*$i/4;
   $y=mt_rand(1,$image_height/4);
   $color=imagecolorallocate($num_image,mt_rand(0,100),mt_rand(0,150),mt_rand(0,200));
   imagestring($num_image,$font,$x,$y,$_SESSION[check_checks][$i],$color);
}
imagepng($num_image);
imagedestroy($num_image);
?>


我通过img标签
使用它,但是图像不会显示,也不会显示错误。我记得我已经在我的实验班上成功地测试了它。所以我想如果我忽略了什么。谢谢你的帮助

您是否已在此PHP安装上安装并启用了GD库?为什么image src有一个PHP文件?@AhmedGinani这很好,可用于此目的。也请改进您老师的代码并编写
$\u会话['check\u checks']
@HankyPanky我已浏览PHPINFO页面,并找到GD库启用。我也不清楚写
$\u会话['check\u checks']
意味着什么。