- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
header() function in PHP
The header() function sends a raw HTTP header to a client.
Syntax
header(string,replace,resp_code)
Parameters
string − The header string to send.
replace − Indicates whether the header should replace previous or add a second header.
resp_code − It forces the HTTP response code to the specified value
Return
The header() function returns nothing.
Example
The following is an example to save a generated PDF −
<?php header("Content-type:application/pdf"); header("Content-Disposition:attachment;filename=output.pdf'"); readfile("demo.pdf"); ?>
The file downloaded will be “output.pdf”, whereas the input is “demo.pdf”.
Advertisements