-1

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.

1
  • 1
    Reading documentation seems to become increasingly difficult. Commented Feb 17, 2009 at 15:03

3 Answers 3

8

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}";
Sign up to request clarification or add additional context in comments.

Comments

7

You're looking for string concantation.

It's

echo $str1 . $str2 . $str3;

See https://www.php.net/language.operators.string for more information.

Comments

2

How about:

echo $str1 . $str2 . $str3;

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.