0

这是下面的代码

class Home extends Public_Controller
{
    /**
     * Constructor method
     *`enter code here`
     * @author PyroCMS Dev Team
     * @access public
     * @return void
     */
    public function __construct()
    {
        parent::__construct();  
    }


public function testimg(){
    header("Content-type: image/png");
    $image = imagecreatetruecolor(200, 200);
    imagepng($image);     
}
}

但是当我像(http://localhost/sitename/home/testimg)一样调用这个控制器时。我得到了下面的错误

无法显示图像“http://localhost/sitename/home/testimg”,因为它包含错误。

请帮我解决这个问题,我是 pyrocms 的新手。

4

2 回答 2

2

已解决的问题:回显某些内容时总是有一个额外的空间,我不知道为什么 - ob_clean()可以完成这项工作。

public function testimg(){
    ob_clean();
    header("Content-type: image/png");
    $image = imagecreatetruecolor(200, 200);
    imagepng($image);     
}
于 2011-10-16T08:11:48.867 回答
0

这与 PyroCMS 甚至 CodeIgniter 无关,您只是设置了错误的图像。这是一个通用的 PHP 错误。

于 2011-10-10T11:06:13.110 回答