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>?></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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

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

Methods to open img files include using virtual optical drive software, using compression software, and using special tools. Detailed introduction: 1. Use virtual optical drive software to open, download and install a virtual optical drive software, right-click the img file, select "Open with" or "Associated Program", select the installed virtual optical drive software in the pop-up dialog box, virtual The optical drive software will automatically load the img file and use it as a disc image in the virtual optical drive. Double-click the disc icon in the virtual optical drive to open the img file and access its contents, etc.

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

How to open the img file: 1. Confirm the img file path; 2. Use the img file opener; 3. Select the opening method; 4. View the picture; 5. Save the picture. The img file is a commonly used image file format, usually used to store picture data.

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

img is a file compression format, mainly used to create image files of floppy disks. It can be used to compress the contents of an entire floppy disk or an entire CD; files with the extension ".IMG" are created using this file format. ; The img file includes 3 basic nodes, namely "Ehfa_HeaderTag", "Ehfa_File" and "Ehfa_Entry".

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

GoClean is a utility for cleaning and managing Go projects. It provides the following commands: Check for cleanable items (check) Fix cleanable items (fix) Build the project and clean the build artifacts (build) Check if the project is clean after building (verify) Benefits include: Optimize code Remove unused dependencies Cleanup Build artifacts integrated with multiple tools such as Gofmt

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

The goclean command is used to delete compilation intermediate files and target files, free up disk space and keep the project clean. Options include: -f: Force deletion without confirmation -n: List files to be deleted -r: Recursively delete dependent packages -i: Ignore specific dependent packages

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

U disk is one of the frequently used storage devices. There will also be some minor problems during use. For example: the U disk cannot be read. How to solve it? Put it away! Can’t read the USB flash drive? 4 steps to teach you how to solve the problem easily. After the USB flash drive has been inserted into the computer, click the Start menu, select Control Panel and put it away! Can’t read the USB flash drive? 4 steps to teach you to easily solve the problem. Find and double-click Device Manager in Control Panel. Keep it! Can’t read the USB flash drive? 4 steps to teach you how to easily solve the problem: Find the Universal Serial Bus controller on the main interface of the Device Manager and put it away! Can’t read the USB flash drive? 4 steps to teach you how to easily find the USB mass storage device, select it, right-click, find Uninstall and put it away! Can’t read the USB flash drive? 4 steps to teach you how to solve the problem easily. Welcome to leave a message for discussion!

How to change the src attribute of img in jquery How to change the src attribute of img in jquery Mar 03, 2022 pm 03:41 PM

How to change the img src attribute in jquery: 1. Use the attr() attribute, the syntax "$("img").attr("src","The address of the image file")"; 2. Use the prop() method, the syntax " $("img").prop("src","The address of the image file")".

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

CAD has many files and caches that we will automatically save during use. Therefore, if we need to uninstall CAD, it is very likely that the uninstallation will not be clean and these files that cannot be used after uninstallation will be retained. At this time, we can find them by method to delete the source file location. How to uninstall cad cleanly in win10 1. First, right-click the start button in the lower left corner of the screen, as shown in the figure. 2. Find the "Applications and Features" at the top 3. Uninstall all Autodesk related software there. 4. After the uninstallation is completed, right-click the start button and open "Run" 5. Enter "regedit" and click "OK" 6. Find the "Autodesk" folder according to the method shown in the figure and delete it. 7. Delete

See all articles