Possible Duplicate:
Headers already sent by PHP
Environment
- Apache 2.2.22
- PHP 5.4.4
- MAC OSX Lion
Disclaimer
I'm very new to PHP and the entire community, and so I'm still learning my way around.
Objective
Redirect to a very specific URL.
Code
I have built my own MVC handler, which I've included below, and I'm trying to handle a specific situation where I am currently at user/login
but I want to redirect back to the home page after logging in so I want to go to home/index
. To do this, I thought, the right way to redirect (after a good bit of searching) was to issue the following command:
header("Location: http://$host$uri/$controllerName/$action");
I have verified that the URL is correct (e.g. if I put the URL in the address bar it would work), but for some reason the browser isn't responding.
Can somebody point me in the right direction?
UPDATE
Below is the error I'm receiving.
Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/test/core/bootstrap.php:66) in /Applications/MAMP/htdocs/test/core/bootstrap.php on line 70
And here is line 66:
if ($_SERVER['DEBUG']) { echo "<br/>$url ..."; }
So, I just can't output anything before trying that it appears?