I have three strings:
$str1 = "abc"; $str2 = "def"; $str3 = "ghi";
I can get the value of all of them like this:
echo "$str1$str2$str3";
But I heard there is a way to join them together, so I can echo all of them without quotes.
I have three strings:
$str1 = "abc"; $str2 = "def"; $str3 = "ghi";
I can get the value of all of them like this:
echo "$str1$str2$str3";
But I heard there is a way to join them together, so I can echo all of them without quotes.
You're looking for string concantation.
It's
echo $str1 . $str2 . $str3;
See http://nz2.php.net/language.operators.string for more information.
As well as concatenating like this
echo $str1 . $str2 . $str3;
You can also just output them in sequence, which avoids evaluating an intermediate string
echo $str1 , $str2 , $str3;
Finally, you can use braces in string to disambiguate string replacement:
echo "{$str1}{$str2}{$str3}";