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 类:全局变量作为类中的属性 2021-01-01
- 如何替换eregi() 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
