Home > Backend Development > PHP Tutorial > Common methods of PHP header() function_PHP tutorial

Common methods of PHP header() function_PHP tutorial

WBOY
Release: 2016-07-13 10:32:54
Original
704 people have browsed it

//Define encoding

//Atom

//CSS

//Javascript

//JPEG Image

//JSON

//PDF

//RSS

//Text (Plain)

//XML

// ok

//Set a 404 header:

//Set the address to be permanently redirected

//Go to a new address

//File delayed redirection:
print 'You will be redirected in 10 seconds';
//Of course, you can also use html syntax to achieve it
// header('Content-Transfer-Encoding: binary');
// load the file to send:
readfile ('example.zip');
//Disable caching for the current document
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
//Set content type:
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain'); //Plain text format
header('Content-Type: image/jpeg'); //JPG***
header('Content-Type: application/zip'); // ZIP file
header('Content-Type: application/pdf'); // PDF file
header('Content-Type: audio/mpeg'); // Audio file
header('Content-Type: application/x-shockw**e-flash'); //Flash animation
//Show login dialog box
header('WWW-Authenticate: Basic realm="Top Secret"');
print 'Text that will be displayed if the user hits cancel or ';
print 'enters wrong login data';

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/753935.htmlTechArticle//Define encoding//Atom //CSS //Javascript //JPEG Image //JSON //PDF / /RSS //Text (Plain) //XML // ok //Set a 404 header: //Set the address to be permanently redirected //Go to a new address...
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template