The PHP header function describes how to set encoding, send HTTP status values, and redirect.
Php header utf8:
header(“Content-type: text/html; charset=utf-8″);
Php headers 404:
header(“HTTP/1.0 404 Not Found”);
The preceding two examples are UTF8 encoding and 404 sending status.
Header redirection:
header(‘Location: http://www.phpthinking.com’);
Other common Header usage:
// The Header is permanently redirected. generally, 301 is used with the header Location. header ('http/1.1 301 Moved Permanently '); header ('Location: http://www.phpthinking.com/'); // The Header delays refreshing the page // with
Same effect header ('refresh: 10; url = http://www.phpthinking.com/'); // Header sets the page language header ('content-language: en'); // for the download page, you can declare the file Type and file name header ('content-Type: application/octet-stream'); header ('content-Disposition: attachment; filename=”filename.zip "'); header ('content-Transfer-Encoding: binary '); // Header set Cache and cache expiration time header ('cache-Control: no-Cache, no-store, max-age = 0, must-revalidate '); header ('expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Header sets the page encoding: header ('content-Type: text/html; charset = utf-8 ′);