php创建图像出现乱码

来源:百度知道 编辑:UC知道 时间:2024/05/17 08:57:27
<?php
$im = imagecreate(100, 30);
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);
imagestring($im, 5, 0, 0, "Hello world!", $textcolor);
header("Content-type: image/png");
imagepng($im);
?>

我本地环境是使用的是 FleaPHP 绿色运行版

我跟你是同样的问题 也不知道为什么
换个方式吧
class showImg
{
var $_source_file = "";
function showImg($file)
{
$this->_source_file = $file;
}

function showImgofMain()
{
$fd=fopen($this->_source_file,"r");
$contents=readfile($this->_source_file);
fclose($fd);
}
}

$sg = new showImg("c:\\rytx.jpg");
$sg->showImgofMain();

这样也是可以输出一张图 我现在用的这个

我用的手工配置。运行正常无错误。