php中施用GD2库创建图形在浏览器中显示不出来

WBOY
Release: 2016-06-13 12:50:35
Original
970 people have browsed it

php中使用GD2库创建图形在浏览器中显示不出来
我刚学PHP不久,在使用GD2库创建图像时在浏览器中显示不出来图像,只有一个代表图像的标志,我的代码如下:
header("content-type:image/gif");
$image = imagecreate(300,80);
$bg = imagecolorallocate($image, 220, 40, 120);
imagegif($image);
?>
应该没问题,但是就是显示不了,各位大侠求指导啊!谢谢!


------解决方案--------------------
你的程序文件是 utf-8 的吧?
请去掉 BOM 头
------解决方案--------------------
本帖最后由 xuzuning 于 2012-07-24 09:04:58 编辑 保存时选gbk编码
------解决方案--------------------
打开php错误提示吧。将header注释掉看提示什么错误。

php.ini 中 
display_errors=On
error_reporting=E_ALL & ~NOTICE  
重启apache 
------解决方案--------------------
假设你的程序名为 pict.php
那么新建一个程序,内容为:
coho base64_encode(file_get_contents('http://localhost/pict.php'));

运行后贴出结果
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!