0

I am trying to incorporate a variable within a PHP header function and it doesn't seem to be working, it shows the actual variable in the address bar or just loads a blank screen. I appreciate your help with this.

The code as follows

header('Location: http://'.$soft_url/main'); 
1
  • 2
    Is that your actual code? That won't work, because there's a syntax error in it. Commented Oct 25, 2012 at 14:27

3 Answers 3

4

That code is formatted wrong.

header('Location: http://'.$soft_url.'/main');

might solve your issue

Sign up to request clarification or add additional context in comments.

7 Comments

Why use single quotes and then go through all the trouble of gluing multiple strings together when double-quotes should do this for you automatically?
No need, PHP will take longer to concatenate.
@tadman - I tend to explicitly concatenate things; I find it makes the code a lot easier to read.
Wrong Single quotes are more efficient when you're not adding variables in the middle of the string.
@andrewsi: any decent code editor can properly colorize php variables, no matter where they are.
|
1

Try this:

header('Location: http://' . $soft_url . '/main'); 

Comments

1

Try this:

header("Location: http://$soft_url/main");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.