Fresh drops for people who build on the web. Explore the collection

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

There are two string operators :

  • Concatenation operator (‘.’) – Concatenation of str1 and str2

Example: $str1 . $str2

  • Concatenating assignment operator (‘.=’) – Appends the str2 to the str1

Example:  $str1 .= $str2

<?php
$str1 = 'PHP';
$str2 = 'Tutorials!';
$str = $str1 . ' ' . $str2;
echo $str; // Output: PHP Tutorials!
?>
Praveen Kumar

Written by Praveen Kumar

I am a fullstack web developer with a passion for SEO, creating stunning websites, and organic marketing. I am a perfectionist.