我試着從現在一段時間來顯示一個用php創建的動態圖像。 我嘗試了不同的教程,他們都沒有工作。最後一次嘗試我做了這個樣子:PHP動態圖像加載
image.php
session_start();
$string = "bla";
$img = imagecreatetruecolor(80,15);
$font_color = imagecolorallocate($img,13,28,91);
$bg_color = imagecolorallocate($img,162,162,162);
imagefill($img,0,0,$bg_color);
imagestring($img, 3, 2, 0, $string, $font_color);
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
test.php的
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
session_start();
echo '<img src="image.php" />';
?>
</body>
</html>
保存圖像工作,我真的不明白什麼即時做錯了所以它加載動態。提前感謝您的任何建議。
你的錯誤是什麼? – 2014-11-14 15:34:25
根本沒有,如果我打電話給test.php,如果我打電話給image.php它的「圖像不能顯示,因爲它包含錯誤」,但儘可能多我已經是紅色的,它不可能在文件中顯示其創建的 – Som1 2014-11-14 15:35:59
手錶對於'<?php'之前的任何空格或image.php – Florent 2014-11-14 15:36:25