Home Backend Development PHP Tutorial Use of header function_PHP tutorial

Use of header function_PHP tutorial

Jul 13, 2016 pm 05:27 PM
header html http by use yes server Header Browser of

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");
>?

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531887.htmlTechArticleHeader is a string sent by the server before transmitting HTML data to the browser using HTTP protocol. A blank line is required between the header and the HTML file. Detailed instructions for HTTP can be found...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The width of emsp spaces in HTML is inconsistent. How to reliably implement text indentation? The width of emsp spaces in HTML is inconsistent. How to reliably implement text indentation? Apr 04, 2025 pm 11:57 PM

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 use the clip-path attribute of CSS to achieve the 45-degree curve effect of segmenter? How to use the clip-path attribute of CSS to achieve the 45-degree curve effect of segmenter? Apr 04, 2025 pm 11:45 PM

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...

How to achieve gap effect on the card and coupon layout with gradient background? How to achieve gap effect on the card and coupon layout with gradient background? Apr 05, 2025 am 07:48 AM

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 real-time application and viewer data on the 58.com work page? How to obtain real-time application and viewer data on the 58.com work page? Apr 05, 2025 am 08:06 AM

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...

Vue2 project online iframe white screen: How to troubleshoot and solve it? Vue2 project online iframe white screen: How to troubleshoot and solve it? Apr 05, 2025 am 06:21 AM

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...

How to accurately track the source of website access, especially the sharing links of apps such as WeChat? How to accurately track the source of website access, especially the sharing links of apps such as WeChat? Apr 05, 2025 am 06:09 AM

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

Is it the crossorigin attribute that cannot load CDN resources in the production environment? Is it the crossorigin attribute that cannot load CDN resources in the production environment? Apr 05, 2025 am 06:06 AM

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...

What is the reason for encoding exceptions when using the request library to get HTML text in Node.js? How to solve it? What is the reason for encoding exceptions when using the request library to get HTML text in Node.js? How to solve it? Apr 05, 2025 am 07:03 AM

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...

See all articles