header("Content-type:text/html;charset=utf-8");

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Lg632/article/details/81538364
header()函数的作用是:发送一个原始 HTTP 标头[Http Header]到客户端。
标头 (header) 是服务器以 HTTP 协义传 HTML 资料到浏览器前所送出的字串,
在标头与 HTML 文件之间尚需空一行分隔。
在 PHP 中送回 HTML 资料前,需先传完所有的标头。

常用header汇总:

header('Content-Type: text/html; charset=utf-8'); //网页编码

header('Content-Type: text/plain'); //纯文本格式

header('Content-Type: image/jpeg'); //JPG、JPEG

header('Content-Type: application/zip'); // ZIP文件

header('Content-Type: application/pdf'); // PDF文件

header('Content-Type: audio/mpeg'); // 音频文件

header('Content-type: text/css');   //css文件

header('Content-type: text/javascript');  //js文件

header('Content-type: application/json'); //json

header('Content-type: application/pdf');  //pdf

header('Content-type: text/xml'); //xml

header('Content-Type: application/x-shockw**e-flash'); //Flash动画

猜你喜欢

转载自blog.csdn.net/Lg632/article/details/81538364