php header function sets the HTTP header method: [header( 'Content-Type: text/html; charset=utf-8 '); ], which means setting the encoding to utf-8.
The example of PHP header function setting HTTP header is as follows:
(Video tutorial recommendation: java video tutorial)
Define encoding
header( 'Content-Type:text/html;charset=utf-8 ');
Set a 404 header:
header('HTTP/1.1 404 Not Found');
Set the address to be permanently redirected
header('HTTP/1.1 301 Moved Permanently');
Go to a new address
header('Location: http://www.example.org/');
File delayed redirection:
header('Refresh: 10; url=http://www.example.org/'); print 'You will be redirected in 10 seconds';
Tell the browser the last modification time
$time = time() - 60; // or filemtime($fn), etc header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
Disable caching for the current document
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Pragma: no-cache');
Related recommendations : php training
The above is the detailed content of How to set HTTP header with php header function. For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Chinese version
Chinese version, very easy to use

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
