Page 1 of 1
Redirect
Posted: Fri Aug 08, 2008 4:43 pm
by guerillacity
is it possible to put a redirect in a function because i get an error when i try:
Code: Select all
function SrtringToLong()
{
header( 'Location: http://www.php.net' ) ;
exit();
}
Re: Redirect
Posted: Fri Aug 08, 2008 5:02 pm
by JB4
On their website it says this:
Code: Select all
<?php
header("Location: http://www.example.com/"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
only differences I notice are:
" instead of '
exit; instead of exit();
I'm not very smart, but I figured I'd tell you what I saw.
Re: Redirect
Posted: Fri Aug 08, 2008 5:09 pm
by xitura
What error message do you get?
Re: Redirect
Posted: Fri Aug 08, 2008 5:26 pm
by guerillacity
i get: Warning: Cannot modify header information.
Re: Redirect
Posted: Fri Aug 08, 2008 5:44 pm
by xitura
That error message is displayed when you have output (anything displayed in the screen + blank spaces and newlines) before the header-function is called.
Re: Redirect
Posted: Fri Aug 08, 2008 6:00 pm
by guerillacity
Cheers i got rid of all the white space even before the first php open.
Works Prefectly. THANKS ALL.