search

Home  >  Q&A  >  body text

php里面的header到底是个什么东西?

php里面的header到底是个什么东西?


phpcn_u226phpcn_u2262985 days ago1146

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 23:03:32

    What exactly is the header in php? -PHP Chinese website Q&A-What exactly is the header in php? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 阿神

    阿神2016-12-20 11:18:29

    头信息的作用很多,最主要的有下面几个:

    1、跳转:当浏览器接受到头信息中的 Location: xxxx 后,就会自动跳转到 xxxx 指向的URL地址,这点有点类似用 js 写跳转。例如:header("Location: http://www.example.com/");

    2、指定网页的内容:同样一个XML文件,如果头信息中指定:Content-type: application/xml 的话,浏览器会将其按照XML文件格式解析。例如:header('Content-type: application/pdf');

    3、附件: 

    // 指定内容为附件
    header('Content-Disposition: attachment; filename="downloaded.pdf"');
    // 打开文件,并输出
    readfile('original.pdf');

    reply
    0
  • Cancelreply