How to change content type in php?(如何更改php中的内容类型?)
问题描述
我有一张图片,但它没有显示.我检查了图像属性(右键单击并选择属性),我发现类型"是 text/html 而不是 JPEG 图像.这是因为导致我的图像不显示的类型吗?如何更改类型"值?我正在使用 php...
I have an image, but it keep doesn't display. I check the image properties (right-click and chose properties), and the I found the "type" is text/html not JPEG image. Is this because the type that cause my images dont show up?? How to change the "Type" value? I am using php...
我在一个简单的 html [img] 标签中显示图像...
I display the image in a simple html [img] tag...
是的,我试过了..如果我包括
Yeah, i tried.. If i include the
<?php header('Content-Type:image/jpeg'); ?>
显示网址,很奇怪吧??
It display the URL, very weird huh??
我用的是apache,图片是php代码生成的……
I am using apache, the image is generated by php code...
<img src="Jmx0Oz9waHAgZWNobyBibG9naW5mbyg="template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "image", $single = true); ?>&h=195&w=540&zc=1&q=95" alt="Jmx0Oz9waHAgdGhlX3RpdGxlKCk7ID8mZ3Q7CjwvY29kZT48L3ByZT4KPHAgY2xhc3M9"cn">
推荐答案
header('Content-Type: image/jpeg');
确保在进行任何输出之前调用 header() 函数,否则您将收到标头已发送"错误.
Make sure to call the header() function before doing any output or you will get a "Headers already sent" error.
这篇关于如何更改php中的内容类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何更改php中的内容类型?


- 带有通配符的 Laravel 验证器 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- Laravel 仓库 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01