【发布时间】:2020-09-07 02:10:57
【问题描述】:
我目前正在尝试在由 Apache (XAMPP) 托管的本地网站上使用 PHP GD 函数显示图像。但是,我的导航器(谷歌浏览器)显示一个带有白色方块而不是红色字符串的黑屏。当我删除“header(...)”行时,它将图像显示为文本。 错误是否来自 Apache 服务器?还是来自“header(...)”行?还是来自其他地方?
非常感谢
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html" charset="UTF-8" />
<title> Title </title>
</head>
<body>
<?php
header("Content-Type: image/png");
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
imagepng($im);
?>
</body>
</html>
【问题讨论】:
标签: php image apache header gd