WEB TUTORIALS
PRACTICE EXAMPLES
HTML REFERENCES
CSS REFERENCES
PHP REFERENCES
SPONSORED LINKS
Advertisements

How to combine two strings in PHP

Topic: PHP / MySQLPrev|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. Let's see how it works:

  • <?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:

Advertisements

Your Feedback:

We would love to hear from you, please drop us a line.