The graph created by using the GD2 Library in php 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 (& quot; content-type: image/gif & quot;); & php uses the GD2 library to create images that 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. In addition, my BOM header is removed, but it cannot be displayed. thank you for your guidance! Thank you!

------ Solution --------------------
The code is okay. Check your environment. Enable the error prompt function.
------ Solution --------------------
Well, it should be an environment setup problem! Download a wamp and enable the gd2 extension!
------ Solution --------------------
You can use the same environment and code on other computers.

------ Solution --------------------
After trying out the code, you can-(only display a sign indicating the image in the upper left corner) change the browser to see it...
------ Solution --------------------
In fact, the GD library is not running normally. use another PHP version.
Discussion

It's useless to change the browser, or the image cannot be displayed, and
If (! Function_exists ("imagecreat "))
Echo "GD support is not installed ";
Else
If (! Function_exists ("imagecreattruecolor "))
Echo "GD2 is installed ";
?> After this code is executed, the output "GD support is not installed" is displayed, but my phpinfo () shows that there is ......

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.