PHP Application GD2 Library creation graphics are not displayed in the browser

Source: Internet
Author: User
Tags php error
Using GD2 Library to create graphics in PHP does not show up in the browser
I just learned PHP soon, when using the GD2 library to create images in the browser to display the image, only a logo representing the image, my code is as follows:
Header ("Content-type:image/gif");
$image = Imagecreate (300,80);
$BG = Imagecolorallocate ($image, 220, 40, 120);
Imagegif ($image);
?>
Should be no problem, but it is not shown, you are the Master of the guide Ah! Thank you!


------Solution--------------------
Your program files are utf-8, right?
Please remove BOM header
------Solution--------------------
This post was last edited by xuzuning on 2012-07-24 09:04:58

Save-Time Select GBK encoding
------Solution--------------------
Open the PHP error prompt. Comment out the header to see what error is being prompted.

In php.ini
Display_errors=on
Error_reporting=e_all & ~notice
Restart Apache
------Solution--------------------
Let's say your program is named pict.php.
Then create a new program with the following content:
Coho Base64_encode (file_get_contents (' http://localhost/pict.php '));

Post the results after running

  • Related Article

    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.