Php 创建图像后获取Black页面

Php 创建图像后获取Black页面,php,Php,下面的代码来自“php.net”。如果我执行它,它会给我一个黑色的页面。有什么我必须声明的还是我遗漏了什么 <?php header('Content-type: image/png'); $resim = imagecreatetruecolor(400, 30); $beyaz = imagecolorallocate($resim, 255, 255, 255); $gri = imagecolorallocate($resim, 128, 128, 128); $siyah =

下面的代码来自“php.net”。如果我执行它,它会给我一个黑色的页面。有什么我必须声明的还是我遗漏了什么

<?php

header('Content-type: image/png');
$resim = imagecreatetruecolor(400, 30);
$beyaz = imagecolorallocate($resim, 255, 255, 255);
$gri = imagecolorallocate($resim, 128, 128, 128);
$siyah = imagecolorallocate($resim, 0, 0, 0);
imagefilledrectangle($resim, 0, 0, 399, 29, $beyaz);
$metin = 'Testing...';
$font = 'arial.ttf';
imagettftext($resim, 20, 0, 11, 21, $gri, $font, $metin);
imagettftext($resim, 20, 0, 10, 20, $siyah, $font, $metin);
imagepng($resim);
imagedestroy($resim);
?>


@johncode请重新打开并重命名此帖子,如何显示标题类型图像的错误。无论您将php错误报告设置为什么,您都不会看到错误输出一次标题('Content-type:image/png');已发送。请注释标题行以查看error@Clint-错误日志将捕获错误。“他们只需要知道怎么看就行了。”约翰纳德·费尔·波因特说。