<?php
error_reporting(E_ALL);
if(file_get_contents("http://localhost/antispam/img.php") == false)
print 'Error';
else
print 'Read successfully';
?>
这总是打印error
。img.php
返回一个 php 生成的图像,但上面的代码无法读取。我的 php.ini 看起来很典型,没有显示错误,我错过了什么?
注意 allow_url_fopen
已设置为On
和1
img.php
$code = 'default';
header("Content-Type: image/jpeg");
$im = @imagecreate(200, 50) or die ("Cannot Initialize new GD image stream");
$bgColour = imagecolorallocate($im, 0, 0, 0);
$textColour = imagecolorallocate($im, 233, 14, 91);
$wSpace = 30; $hSpace = 20;
$prevW = 0;
for($i = 0; $i < strlen($code); $i++)
{
$w = $prevW + rand(20, $wSpace);
imagestring($im, 5, $w, rand(0,$hSpace), substr($code, $i, 1), $textColour);
$prevW = $w;
}
imagejpeg($im);
imagedestroy($im);