How can I use multiple PHP header content types on the same page? is this possible?(如何在同一页面上使用多个 PHP 标头内容类型?这可能吗?)
问题描述
是否可以在一个文档中使用多种标题类型?例如:
Is it possible to use multiple header types in one document? For example:
header("Content-type: image/jpeg");
header('Content-Type: text/html; charset=utf-8');
将整个页面返回为 text/html... 而
returns the whole page as text/html... while
header('Content-Type: text/html; charset=utf-8');
header("Content-type: image/jpeg");
将整个页面作为图像返回.... 如何在同一页面上使用两种类型的内容?我在顶部使用 ob_start(),在开头使用 ob_end_flush().
Returns the whole page as an image.... How can I use both types of content on the same page? I'm using ob_start() at the top and ob_end_flush() at the beginning.
推荐答案
你不能.但是你可以在你的 HTML 中做这样的事情:
You can't. But what you can do is something like this in your HTML:
<img src="bXlfaW1nLnBocA==" />
当然 my_img.php
是一个 PHP 文件,它有一个 header("Content-type: image/jpeg");
行,并输出您的图像.
Of course my_img.php
would be a PHP file that has a header("Content-type: image/jpeg");
line, and outputs your image.
这篇关于如何在同一页面上使用多个 PHP 标头内容类型?这可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在同一页面上使用多个 PHP 标头内容类型?这可能吗?


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