How to combine two strings in PHP

Topic: PHP / MySQL« Prev|Next »

Answer: Use the PHP Concatenation Operator

You can use the PHP concatenation operator (.) to combine or join two strings together in PHP. This operator is specifically designed for strings.

  • <?php
  • $str1 = 'Hello';
  • $str2 = 'World!';
  • $new_str = $str1 . ' ' . $str2;
  • echo $new_str; // Outputs: Hello World!
  • ?>

Related FAQ

Here are some more FAQ related to this topic:


Your Feedback:


We would love to hear from you! Please say something.