Use of header function_PHP tutorial
The header is a string sent by the server before transmitting HTML data to the browser using the HTTP protocol. A blank line is required between the header
and the HTML file. For detailed instructions on HTTP, please refer to the RFC 2068 official document
(http://www.w3.org/Protocols/rfc2068/rfc2068). Before sending back HTML data in PHP, all headers must be
passed.
Note: Traditional headers must contain one of the following three headers and can only appear once.
Content-Type: xxxx/yyyy
Location: xxxx:yyyy/zzzz
Status: nnn xxxxxx
Can appear more than twice in the new multipart header specification (Multipart MIME).
Usage Example
Example 1: This example redirects the browser to the official website of PHP.
Header("Location: http://www.php.net");
exit;
>?
Example 2: To allow users to get the latest data every time, instead of For data in Proxy or cache, you can use the following header
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate(" D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
>?
Example 3: Let the user's browser display a message that the file cannot be found.
header("Status: 404 Not Found");
>?
Example 4: Allow users to download files.
header("Content-type: application/x-gzip");
header("Content-Disposition: attachment; filename=filename");
header("Content-Description: PHP3 Generated Data");
>?

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Regarding the problem of inconsistent width of emsp spaces in HTML and Chinese characters in many web tutorials, it is mentioned that occupying the width of a Chinese character, but the actual situation is not...

How to achieve the 45-degree curve effect of segmenter? In the process of implementing the segmenter, how to make the right border turn into a 45-degree curve when clicking the left button, and the point...

Realize the gap effect of card coupon layout. When designing card coupon layout, you often encounter the need to add gaps on card coupons, especially when the background is gradient...

How to obtain dynamic data of 58.com work page while crawling? When crawling a work page of 58.com using crawler tools, you may encounter this...

Troubleshooting and solving the online white screen of iframe in Vue2 project. In the development of Vue2 project, we often use iframes to embed other web content. However, the item...

Tracking website access sources: Using HTTP request headers and URL parameters to accurately track access sources when building a statistical website. Developers often...

Regarding the problem of the crossorigin attribute of script tag, the online resource cannot be loaded. In front-end development, we often use CDN to introduce external JavaScript libraries to...

The reason and solution for coding exceptions when using the request library to obtain HTML text content in the Node.js environment. During the development process of using Node.js, it is often necessary to...
