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:
Example
Run this code »<?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: