Using the GD2 Library in php to create images cannot be displayed in the browser

Source: Internet
Author: User
Using the GD2 Library in php to create images cannot be displayed in the browser. I just learned PHP and cannot display images in the browser when using the GD2 library to create images, there is only one icon representing the image. my code is as follows: & lt ;? Php & nbsp; header ("content-type: image/gif"); $ images created using the GD2 Library in php cannot be displayed in the browser
Shortly after I first learned PHP, when I used the GD2 library to create an image, I couldn't display the image in the browser. there was only one icon representing the image. my code is as follows:
Header ("content-type: image/gif ");
$ Image = imagecreate (, 80 );
$ Bg = imagecolorallocate ($ image, 220, 40,120 );
Imagegif ($ image );
?>
It should be okay, but it cannot be displayed. thank you for your guidance! Thank you!
------ Solution --------------------
Is your program file UTF-8?
Remove BOM header
------ Solution --------------------
At the end of this post, xuzuning selects gbk encoding when editing and saving at 09:04:58.
------ Solution --------------------
Open the php error prompt. Comment out the header to see what error is prompted.

Php. ini
Display_errors = On
Error_reporting = E_ALL &~ NOTICE
Restart apache
------ Solution --------------------
Assume that your program is named pict. php.
Create a program with the following content:
Coho base64_encode (file_get_contents ('http: // localhost/pict. php '));

Post the result after running

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.