php 内容类型

发布于 2024-10-14 14:14:00 字数 640 浏览 10 评论 0原文

我正在尝试将动态数据从数据库导出到浏览器。 我看到有不同的内容类型,有些我需要询问。我肯定问错了问题,因为我在搜索引擎中找不到详细信息。

以下是我从人们的个人脚本中看到的一些内容。

header("Content-type: application/zip;");
header("Content-type: application/csv");
header("Content-type: application/x-msdownload");
header('Content-Type: application/vnd.ms-excel');
header('Content-type: application/octet-stream');

我可以清楚地理解“zip”,“csv”。但其他人却给我留下了疑问。比如,我什么时候使用它们?

我已经尝试过 x-msdownload for xls 文件,它似乎有效。但我看到其他人使用 vnd.ms-excel。为什么?我应该用那个吗? 我还看到 octet-stream 用于下载由 php 生成的 csv 文件。为什么?

不管怎样,我在 php.net 上没有找到太多东西。并不是说它不存在,而是没有显示清晰的描述。

有人知道有一个网站可以分解不同的内容类型吗?为什么要使用它们?

I'm playing around with exporting dynamic data from a database to the browser.
I see there are different Content-Types, and some I need to ask about. I must be asking the wrong questions, since I'm not finding detailed information in the search engines.

here's a few I've seen from people's personal scripts.

header("Content-type: application/zip;");
header("Content-type: application/csv");
header("Content-type: application/x-msdownload");
header('Content-Type: application/vnd.ms-excel');
header('Content-type: application/octet-stream');

I can clearly understand "zip", "csv". But the others leave me with questions. Like, when do i use them?

I've tried x-msdownload for xls files, and it seems to work. But I see others using vnd.ms-excel. Why? Should I be using that?
I've also see octet-stream used for downloading a csv file, generated by php. Why?

Anyway, I'm not finding much on php.net. Not to say it's not there, but clear descriptions aren't shown.

Anyone know of a site that breaks down the different content-types, and why they're used?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空心↖ 2024-10-21 14:14:00

http://www.iana.org/assignments/media-types/ 有一个MIME 类型及其相关定义的详尽列表。

http://www.iana.org/assignments/media-types/ has an exhaustive list of mime types and their associated definition.

十二 2024-10-21 14:14:00

MIME 类型不是由 PHP 定义的,而是由 IETF 在 RFC2046。它们中的大多数仅适用于单一文件类型,并且仅在您想贡献此类文件时才有用。以 vnd 开头的类型是供应商特定的 MIME 类型。以x- 开头的类型未定义。它们的意思是“我的自定义类型”,但您不应该依赖它。 text/plain 通常用于不接近定义的 ascii 内容,而 application/octet-stream 对于二进制内容几乎相同。

The MIME-Types are not defined by PHP, but they are defined by the IETF in RFC2046. Most of them are just for single file types and only useful, if you want to contribute such files. Types starting with vnd are vendor specific MIME-Types. Types starting with x- are not defined. They mean something like "my custom type", but you should not rely on it. text/plain is usually used for not nearer defined ascii content and application/octet-stream is nearly the same for binary content.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文