0

while trying this, I get error. is there a way to do it? I can assign multiple strings to a single variable but I don't know why it doesn't work with another variables.

$var1 = "Hello";
$var2 = "There";

$var3 = $var1, $var2;

echo $var3,  "<br />";
Cœur
  • 37,241
  • 25
  • 195
  • 267
fcbrmadrid
  • 99
  • 4
  • Have a look at these questions [http://stackoverflow.com/questions/15163596/assigning-multiple-variables-to-a-single-in-php][1] [http://stackoverflow.com/questions/17057229/php-assigning-multiple-strings-to-a-single-variable][2] – Kashif Atiq Nov 22 '14 at 21:13

1 Answers1

0

Use concat like this:

(Or maybe you just made a typo because , is directly to the left of .)

$var1 = "Hello";
$var2 = "There";

$var3 = $var1 . " " . $var2;

echo $var3 . "<br />";

See for further reference:

http://php.net/manual/en/language.operators.string.php

Rizier123
  • 58,877
  • 16
  • 101
  • 156