I've been looking and looking and cannot seem to find how to do this at php.net. I just want to create a variable that combines (not mathematically) several variables and text together.
For example:
$variableA = "sample1"
$variableB = "sample2"
$combo = "VariableA=" & $variableA & "&VariableB=" & $variableB;
I want the $combo variable to produce this: "VariableA=sample1&VariableB=sample2"
Using the "&" character to combine them works in ASP, but I can't find how to do this in PHP. Please help.
How do I combine variables/text?
Moderator: General Moderators
the dot operator
I saw in your message that you actually used the correct operator 5 times you just didn't know it.
In php we use the dot operator for piecing lines togther.
Like so:
Should result in VariableA=sample1&VariableB=sample2
Also php is some what forgiving so you could also get away with
And you would end up with the same result.
phpScott
In php we use the dot operator for piecing lines togther.
Like so:
Code: Select all
$combo = "VariableA= " . $variableA . "&VariableB= " . $variableB . "<br />;
print $combo;Also php is some what forgiving so you could also get away with
Code: Select all
$combo = "VariableA= $variableA &VariableB= $variableB <br />;phpScott