How to combine two strings in PHP
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! ?>
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Use the PHP Concatenation Operator
You can use the PHP concatenation operator (
need an explanation for this answer? contact us directly to get an explanation for this answer.) to combine or join two strings together in PHP. This operator is specifically designed for strings. Let's see how it works: