|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Headers with include!
Hi,
I'm new to PHP and I'm having some trouble to figure out how to solve a prob. I want to evaluate a criteria inside a control structure statement, which needs some variables from an include, like this: Code:
include 'myinclude.php';
if ($example){
//code goes here
}else{
header("Location: http://example.com");
}
The problem is that I can't redirect my page after the else statement because of the include (I suppose). How could I solve this or is there a way I can redirect with PHP after the "else" without getting the header error? 'Warning: Cannot modify header information - headers already sent by' Thanks a lot ![]() |
|
#2
|
|||
|
|||
|
1 - The clean way - http://www.php.net/ob_start
2 - The ghetto way - Use the function: headers_sent() http://www.php.net/headers_sent to find out if headers (output) has been sent to the browser already... if not, use a Location / Header, otherwise, you will simply output an html based header (client side header)
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#3
|
|||
|
|||
|
BTW, you will find most of what you need in the user comments on the www.php.net site:
http://us2.php.net/headers_sent |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Headers with include! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|