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

WBOY
Release: 2016-07-30 13:31:16
Original
1446 people have browsed it

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>?></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.

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!