PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How do I send HTTP headers with PHP?


This is done with the header function, another very handy built-in PHP function.

Here is an example of using header to re-direct to a different webpage:

<?php
header
("Location: http://www.php-questions.com");
?>


There are two mistakes that everyone makes with header the first time they use it so since we're feeling nice, we'll tell you up front to stop some head scratching.

First, the header command must be called before anything is sent to the web browser, otherwise a nice error message will occur.

Second, you'll want to stop execution of the script after the header call, so be sure to include exit; directly underneath. We just saved you a whole load of hassle!



Comment on this Question and Answer >>>

ASK A QUESTION

More website PHP Questions

where do i go to paste my google adsense code?

I have uploaded a vbforum which is al coded in php. and i also have a php.ini file. i turned the display_errors off. so now whern i try to go to the site i see a blank page. And everything is correctly coded because i didn't change anything. But it works

How can I find out where a site visitor comes from?

how can i add a chatbox to my site?

How can I use sessions in PHP?



Custom Search