Php imagesetpixel()在循环中不工作
我正在尝试使用PHP开发一个热图。该文件从文本文件中获取坐标值的输入,并使用PHP代码将这些值映射到屏幕上。我不知道我的代码有什么问题,但它没有生成任何图像。我正在附上密码Php imagesetpixel()在循环中不工作,php,Php,我正在尝试使用PHP开发一个热图。该文件从文本文件中获取坐标值的输入,并使用PHP代码将这些值映射到屏幕上。我不知道我的代码有什么问题,但它没有生成任何图像。我正在附上密码 <?php $width = 1024; $height = 768; $splitted[]=""; $splitted1[]=""; $x=""; $y=""; $x_value[]=""; $y_value[]=""; $im = imagecreatetruecolor($width, $height);
<?php
$width = 1024;
$height = 768;
$splitted[]="";
$splitted1[]="";
$x="";
$y="";
$x_value[]="";
$y_value[]="";
$im = imagecreatetruecolor($width, $height);
$red = imagecolorallocate($im, 255, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$blue = imagecolorallocate($im, 0, 0, 255);
$gray = imagecolorallocate($im, 0xC0, 0xC0, 0xC0);
imagefill($im, 0, 0, $black);
$file = "clickcount.txt";
$fp = fopen($file, 'r') or die("error opening file");
$file = fread($fp, filesize($file));
$splitted = explode(":", $file);
for ($i = 0; $i < count($splitted); $i++)
{
if (!is_string($splitted[$i]))
return false;
//$arr_query = NULL;
$url = parse_url($splitted[$i]);
$url = $url['query'];
parse_str($url, $vars);
$x = intval($vars['x']);
$y = intval($vars['y']);
$x_value[$i]=$x;
$y_value[$i]=$y;
//imagesetpixel($im, $x, $y, $white);
//$splitted1=explode("?",$splitted[$i]);
}
for($i = 0; $i <( count($x_value)-1); $i++)
{
echo "inside the loop";
echo $x_value[$i];
echo $y_value[$i];
imagesetpixel($im, $x_value[$i], $y_value[$i], $white);
}
header('Content-Type: image/png');
imagepng( $im );
imagedestroy($im);
?>
你自己调试过吗?检查x\u值/y\u值数组是否包含任何内容?检查您的各种for()循环是否正在实际执行?在输出标头之前,您不能回显任何内容。如果您这样做,您将得到一个php错误。
/musicstore/empty.php?x=437&y=392:
/musicstore/empty.php?x=407&y=631:
/musicstore/empty.php?x=135&y=305:
/musicstore/empty.php?x=199&y=420:
/musicstore/empty.php?x=290&y=426:
/musicstore/empty.php?x=408&y=435:
/musicstore/empty.php?x=1099&y=398:
/musicstore/empty.php?x=1104&y=256:
/musicstore/empty.php?x=1115&y=62:
/musicstore/empty.php?x=1032&y=146:
/musicstore/empty.php?x=1022&y=262:
/musicstore/empty.php?x=757&y=246:
/musicstore/empty.php?x=752&y=365:
/musicstore/empty.php?x=750&y=417:
/musicstore/empty.php?x=752&y=485: