【发布时间】:2014-12-08 17:59:44
【问题描述】:
我正在使用下面的代码来显示一个图像,其中显示了有多少用户连接到我的网站的文本。我用不同的图像替换了我使用“vad.png”的图像。现在我收到错误“图像无法显示,因为它包含错误”
有人知道我该如何解决这个问题吗?
$result = mysql_query("SELECT * FROM server_status");
$row = mysql_fetch_array( $result );
$text = "Online";
$image = imagecreatefrompng('vad.png');
$black = imagecolorallocate($image, 10, 0, 0);
if (strlen($row['users_online']) >= 3){
imagefttext($image, 11, 0, 435, 38, $black, './verdana.ttf', $row['users_online']);
}
else
{
imagefttext($image, 11, 0, 440, 38, $black, './verdana.ttf', $row['users_online']);
}
imagefttext($image, 8, 0, 432, 55, $black, './verdana.ttf', $text); // Remove the // ahead of this line to use it
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
【问题讨论】:
-
你用文本和 css 做这个,为什么首先使用图像。