Home Backend Development PHP Tutorial PHP fails to draw pictures, which can be solved by clearing the cache ob_clean.

PHP fails to draw pictures, which can be solved by clearing the cache ob_clean.

Jul 30, 2016 pm 01:31 PM
200 clean img

When using php to create a picture, the picture cannot be generated normally

<code><span>header</span>(<span>"Content-type: image/png"</span>);
<span>$img</span><span>=</span>imagecreatetruecolor(<span>200</span>,<span>200</span>);
imagepng(<span>$img</span>);
imagedestroy(<span>$img</span>);</code>
Copy after login

The picture that appears is this:
PHP fails to draw pictures, which can be solved by clearing the cache ob_clean.
After clearing the cache, it will display normally. Add
ob_clean();

The code is as follows:

<code><span><span><?php </span>
ob_clean();
header(<span>"Content-type: image/png"</span>);
<span>$img</span>=imagecreatetruecolor(<span>200</span>,<span>200</span>);
imagepng(<span>$img</span>);
imagedestroy(<span>$img</span>);
<span>?&gt;</span></span></span></code>
Copy after login

PHP fails to draw pictures, which can be solved by clearing the cache ob_clean.

The above introduces the failure of php to draw pictures, which can be solved by clearing the cache ob_clean. , including relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to open img file How to open img file Sep 18, 2023 am 09:40 AM

How to open img file

How to open img file How to open img file Jul 06, 2023 pm 04:17 PM

How to open img file

Go clean detailed explanation: efficient cleaning of compiled products Go clean detailed explanation: efficient cleaning of compiled products Apr 07, 2024 pm 12:03 PM

Go clean detailed explanation: efficient cleaning of compiled products

What is the format of img? What is the format of img? Mar 17, 2023 am 10:33 AM

What is the format of img?

Go clean guide: Cleaning and managing Go projects Go clean guide: Cleaning and managing Go projects Apr 07, 2024 am 10:36 AM

Go clean guide: Cleaning and managing Go projects

U disk pe cannot read img U disk pe cannot read img Mar 19, 2024 pm 12:07 PM

U disk pe cannot read img

what does image tag mean in html what does image tag mean in html Mar 04, 2021 pm 02:37 PM

what does image tag mean in html

Win10CAD complete uninstall guide Win10CAD complete uninstall guide Dec 23, 2023 pm 09:31 PM

Win10CAD complete uninstall guide

See all articles