温馨提示×

php header Content-Type类型是什么

PHP
小亿
355
2023-08-11 11:00:25
栏目: 编程语言

Content-Type是HTTP头部字段之一,用于指定请求或响应中的实体主体的媒体类型。在PHP中,可以使用header()函数来设置Content-Type类型。

常见的Content-Type类型有:

  • text/plain:纯文本类型

  • text/html:HTML文档类型

  • text/css:CSS样式表类型

  • application/json:JSON数据类型

  • application/xml:XML数据类型

  • application/pdf:PDF文档类型

  • image/jpeg:JPEG图片类型

  • image/png:PNG图片类型

使用PHP设置Content-Type类型的示例代码如下:

header('Content-Type: text/html');

上述代码将设置Content-Type类型为text/html,表示返回的是HTML文档类型的内容。

0