Hi
if I have a variable
say
$sausage = something
How do I put that variable in the header direct
i.e
header("Location: http://mysite.com/?tid=$sausage");
does not work.
How do I do it???
Thanks.
Tate.
how to echo php variable in a header direct
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: how to echo php variable in a header direct
Variables are parsed within double quotes, so it actually is working. I would suspect the value of $sausage is not what you expect.
Alternatively, you can escape the quotes or use single quotes.
Are all perfectly legit. Try var_dump($sausage); before the header call to see what the value of $sausage is.
Alternatively, you can escape the quotes or use single quotes.
Code: Select all
header("Location: http://mysite.com/?tid=$sausage");
header("Location: http://mysite.com/?tid=". $sausage);
header('Location: http://mysite.com/?tid='. $sausage);Re: how to echo php variable in a header direct
Thats great!
It works!! Thanks!
If I wanted it to open a new webpage, so my site site still remains, how do I do that???
It works!! Thanks!
If I wanted it to open a new webpage, so my site site still remains, how do I do that???
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: how to echo php variable in a header direct
You will have to use html/javascript. A header redirect has no control of the client.tate wrote:Thats great!
It works!! Thanks!
If I wanted it to open a new webpage, so my site site still remains, how do I do that???