一个简单的php画图有关问题、
一个简单的php画图问题、、、
我在php页面上写如下代码:
//header('Content-Type:text/jpeg'); //这地方如果注释了就能执行正确。
$im=imagecreatetruecolor(200,200);
imagepng($im);
?>
如果上面的地方不注释就不能把图片画出来。浏览器还提示下载(下载了也不是个图片)呀,还是打开(打开之后是乱码)。
问题:画图不都得有这个header()来指定类型吗? 是不是跟php.ini 的配置文件有关呀?还是其他的原因,想不出来了
------解决方案--------------------
你输出浏览器,你得告诉它,你要向别人输出什么类型的东西吧??
比如html之类的就是 text/html....
------解决方案--------------------
我有点不理解,注释掉的话MIME类型就应该是text/html了,怎么还会显示图片呢?
另外你输出的是png格式,header发送的却是jpeg格式。改一致看看
------解决方案--------------------
header('Content-Type:image/png'); //注意:是image而不是text
$im=imagecreatetruecolor(200,200);
imagepng($im);
红色的要配套
是否需要类型声明的头,取决于浏览器的种类
------解决方案--------------------
header('Content-Type:image/jpeg'); image才是指定图片类型。
------解决方案--------------------
例子 1. 新建一个新的 GD 图像流并输出图像

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



[SpringBoot] Passing parameters in the Header through Feign calls How to pass Header parameters through Feign Problem description When we use Feign to request the Api interface of another service in Spring Cloud, there is a need to pass the parameters in the Header. If no special processing is done, it will The parameters in the Header will be lost. Solution 1: Pass it through @RequestHeader(name="headerName"). For example: Feign is defined as follows @FeignClient(name="service-name")pub

The Linux header refers to the beginning of a file or data stream, which is used to contain metadata about the content. By correctly writing and using Header files, developers can better utilize system resources and improve code readability and Maintainability.

This article will introduce seven ways to get high-quality output using the free BingImageCreator. BingImageCreator (now known as ImageCreator for Microsoft Designer) is one of the great online artificial intelligence art generators. It generates highly realistic visual effects based on user prompts. The more specific, clear, and creative your prompts are, the better the results will be. BingImageCreator has made significant progress in creating high-quality images. It now uses Dall-E3 training mode, showing a higher level of detail and realism. However, its ability to consistently produce HD results depends on several factors, including fast

How to delete images on Xiaomi mobile phones? You can delete images on Xiaomi mobile phones, but most users don’t know how to delete images. Next is the tutorial on how to delete images on Xiaomi mobile phones brought by the editor. Interested users can come and join us. Let's see! How to delete images on Xiaomi mobile phone 1. First open the [Album] function in Xiaomi mobile phone; 2. Then check the unnecessary pictures and click the [Delete] button in the lower right corner; 3. Then click [Album] at the top to enter the special area , select [Recycle Bin]; 4. Then directly click [Empty Recycle Bin] as shown in the figure below; 5. Finally, directly click [Permanent Delete] to complete.

PHP is a powerful programming language that can be used to create dynamic websites and web applications. One of the most powerful features is PHP’s header() method. In this article, we will explore how to use PHP’s header() method to adjust web pages.

How to implement jump in php header: 1. Use "Header("Location:$url");" syntax to implement jump; 2. Use if judgment to implement jump, with jump statements such as "if($_COOKIE[" u_type"]){ header('location:register.php'); } else{ setcookie('u_type','1','86400*360');".

Differences: 1. The head tag is used to define the head of the document, which is a container for all head elements, and the header tag is used to define the header (introduction information) of the document; 2. All browsers support the head tag, and older versions of browsers None of the browsers support the header tag, and browsers such as IE9+ and above are required to support the header tag.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code
