search
HomeBackend DevelopmentPHP TutorialPHP fails to draw pictures, which can be solved by clearing the cache ob_clean.

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
img文件怎么打开img文件怎么打开Sep 18, 2023 am 09:40 AM

打开img文件的方法有使用虚拟光驱软件打开、使用压缩软件打开和使用专用工具打开。详细介绍:1、使用虚拟光驱软件打开,下载并安装一个虚拟光驱软件,右键单击img文件,选择“打开方式”或“关联程序”,在弹出的对话框中选择安装的虚拟光驱软件,虚拟光驱软件会自动加载img文件,并将其作为虚拟光驱中的光盘映像,双击虚拟光驱中的光盘图标,即可打开img文件并访问其中的内容等等。

img文件如何打开img文件如何打开Jul 06, 2023 pm 04:17 PM

img文件打开的方式:1、确认img文件路径;2、使用img文件打开器;3、选择打开方式;4、查看图片;5、保存图片。img文件是一种常用的图像文件格式,通常用于存储图片数据。

Go clean详解:高效清理编译产物Go clean详解:高效清理编译产物Apr 07, 2024 pm 12:03 PM

goclean命令用于删除编译中间文件和目标文件,释放磁盘空间并保持项目整洁。选项包括:-f:强制删除,无需确认-n:列出将要删除的文件-r:递归删除依赖包-i:忽略特定依赖包

img是什么格式img是什么格式Mar 17, 2023 am 10:33 AM

img是一种文件压缩格式,主要是为了创建软盘的镜像文件,它可以用来压缩整个软盘或整片光盘的内容;使用“.IMG”这个扩展名的文件就是利用这种文件格式来创建的;img文件包括3个基本节点,分别是“Ehfa_HeaderTag”、“Ehfa_File”和“Ehfa_Entry”。

Go clean指南:清理和管理Go项目Go clean指南:清理和管理Go项目Apr 07, 2024 am 10:36 AM

GoClean是一款用于清理和管理Go项目的实用程序。它提供了以下命令:检查可清理项(check)修复可清理项(fix)构建项目并清理构建工件(build)检查构建后项目是否干净(verify)好处包括:优化代码删除未使用的依赖项清理构建工件集成多种工具,如Gofmt

u盘pe读不出imgu盘pe读不出imgMar 19, 2024 pm 12:07 PM

U盘是经常用到的储存设备之一,那在使用过程中也会出现一些小问题,比如:U盘读不出,那该怎么解决呢?收好!u盘读不出来?4步教你轻松解决在U盘已经插到电脑的基础上点击开始菜单,选中控制面板收好!u盘读不出来?4步教你轻松解决在控制面板里找到并双击设备管理器。收好!u盘读不出来?4步教你轻松解决在设备管理器的主界面找到通用串行总线控制器收好!u盘读不出来?4步教你轻松解决找到usb大容量存储设备,选中它点击右键找到卸载收好!u盘读不出来?4步教你轻松解决欢迎留言讨论哟!

在html中图像标签是什么意思在html中图像标签是什么意思Mar 04, 2021 pm 02:37 PM

在html中,图像标签是指用于定义图像的标签,即“<img>”标签。img元素可以向网页中嵌入一幅图像,“<img>”标签的作用是为被引用的图像创建占位符,将图像链接到HTML页面上;img标签使用src属性来规定显示图像的URL,语法“<img src="图像url">”。

jquery怎么改变img的src属性jquery怎么改变img的src属性Mar 03, 2022 pm 03:41 PM

jquery改变img src属性的方法:1、使用attr()属性,语法“$("img").attr("src","图片文件的地址")”;2、使用prop()方法,语法“$("img").prop("src","图片文件的地址")”。

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft