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.

WBOY
WBOYOriginal
2016-07-30 13:31:161528browse

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>

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>

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:
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