-
- // The result is wrong
- // There is already output before calling header()
- header('Location: url');
- ?>
Copy code
Two: Disable browser cache
-
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Cache-Control: no-cache");
- header("Pragma: no-cache") ;
Copy code
Three: Prompt to save a generated PDF file (the Content-Disposition header is used to provide a recommended file name and force the browser to display a save dialog box):
-
-
header("Content-type:application/pdf");
// The file will be called downloaded.pdf
- header("Content-Disposition:attachment;filename='downloaded.pdf'");
// The PDF source is in original.pdf
- readfile("original.pdf");
- ? >
-
Copy the code
Four: Let the visitor's browser display a 404 prompt.
-
- //404 not found
- header("Status: 404 Not Found");
- ?>
Copy code
|