The functions of headers in PHP include many jumps and sending header information. In addition to these two functions, are there other functions? Let's take a look at common examples of commonly used headers in PHP.
Record commonly used header information here
header('HTTP/1.1 200 OK'); // ok normal access
header('HTTP/1.1 404 Not Found'); //Notify the browser that the page does not exist
header('HTTP/1.1 301 Moved Permanently'); //Set the address to be permanently redirected 301
header('Location: http://www.ruonu.com/'); //Jump to a new address
header('Refresh: 10; url=http://www.ruonu.com/'); //Delayed redirection, that is, jump every few seconds
header('X-Powered-By: PHP/7.0.0'); //Modify X-Powered-By information
header('Content-language: en'); //Document language
header('Content-Length: 1234'); //Set content length
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); //Tell the browser the last modified time
header('HTTP/1.1 304 Not Modified'); //Tell the browser that the document content has not changed
###Content Type###
header('Content-Type: text/html; charset=utf-8'); //Web page encoding
header('Content-Type: text/plain'); //Plain text format
header('Content-Type: image/jpeg'); //JPG, JPEG
header('Content-Type: application/zip'); // ZIP file
header('Content-Type: application/pdf'); // PDF file
header('Content-Type: audio/mpeg'); // Audio file
header('Content-type: text/css'); //css file
header('Content-type: text/javascript'); //js file
header('Content-type: application/json'); //json
header('Content-type: application/pdf'); //pdf
header('Content-type: text/xml'); //xml
header('Content-Type: application/x-shockw**e-flash'); //Flash animation
######
###Declare a downloaded file###
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="ITblog.zip"');
header('Content-Transfer-Encoding: binary');
readfile('test.zip');
######
###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');
######
###Display a login dialog box that requires verification###
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');
######
###Declare an xls file that needs to be downloaded###
header('Content-Disposition: attachment; filename=ithhc.xlsx');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Length: '.filesize('./test.xls'));
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');
header('Pragma: public');
readfile('./test.xls');
######