header('Location: http://www.example.com/')

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thamizh
Forum Newbie
Posts: 18
Joined: Wed Apr 14, 2010 7:25 am

header('Location: http://www.example.com/')

Post by thamizh »

header('Location:http://www.test.com/")
why this syntax that is header is not working in the localhost
it does not makes a redirection
am using javascript(window.location for redirection)
pls give me a solution for this problem
roders
Forum Commoner
Posts: 68
Joined: Tue Oct 20, 2009 9:29 am

Re: header('Location: http://www.example.com/')

Post by roders »

correct syntax for this is

Code: Select all

header('Location:http://www.test.com/');
Do you get any error message when you run it?
solid
Forum Commoner
Posts: 28
Joined: Wed Aug 12, 2009 11:56 am

Re: header('Location: http://www.example.com/')

Post by solid »

Just for clarity, you were opening with a single-quote, and ending with a double-quote.
thamizh
Forum Newbie
Posts: 18
Joined: Wed Apr 14, 2010 7:25 am

Re: header('Location: http://www.example.com/')

Post by thamizh »

now the header syntax works for me :D
but sometimes am getting this warning :Headers already sent
why this warning comes ? :(
Bind
Forum Contributor
Posts: 102
Joined: Wed Feb 03, 2010 1:22 am

Re: header('Location: http://www.example.com/')

Post by Bind »

that error means the script output something before the header(), whether that be whitepace, lines, or html.

remove the items being output prior to the header() call or use php output buffer control
Post Reply