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="my_img.php" />
当然 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 标头内容类型?这可能吗?


基础教程推荐
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- php中的foreach复选框POST 2021-01-01
- 将变量从树枝传递给 js 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- php中的PDF导出 2022-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01