我尝试通过 PHP GD 制作验证码。但不幸的是我遇到了一个问题!
PHP 告诉我:
The image “http://127.0.0.1/par.php” cannot be displayed because it contains errors.
我的代码是这样的
<?php
header ('Content-Type: image/png');
$im = @imagecreatetruecolor(120, 20)
or die('Cannot Initialize new GD image stream');
$text_color = imagecolorallocate($im, 233, 14, 91);
$red = imagecolorallocate($im, 255, 0, 0);
for ($i=0;i<=120;$i=$i+1){
for ($j=0;$j<=20;$j=$j+1){
imagesetpixel($im, $i,$j,$red);
}
}
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
imagepng($im);
imagedestroy($im);
?>
$im = @imagecreatetruecolor(120, 20)
or die('Cannot Initialize new GD image stream');
您首先隐藏真正的错误并尝试显示一些内容......
你无法显示它,因为你不寻找它,
并公开图像,无论它是否真的生成。
然后你继续使用 stackoverflow 并希望有人能猜出你可能简单地抑制的错误@
操作员。
确保之前没有任何东西<?php
如果有,请删除?>
在最后。
为了确保您已经安装了 GD,请在新的 php 文件中尝试以下操作:
<?php
if (extension_loaded('gd') && function_exists('gd_info')) {
echo "PHP GD library is installed on your web server";
}
else {
echo "PHP GD library is NOT installed on your web server";
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)