In this tutorial we will learn How To append a String in PHP. We can use PHP concatenation assignment operator or dot with equal sign to append a string in PHP.
Table of Contents
Using Concatenation Operator (.=)
We can simply use Concatenation Assignment Operator (.=) to append a string in PHP.
No need to use any function or method for this.
Take a look at the code given below.
<?php
$string = 'Hello';
$string .= "World!";
echo $string;
?>
This will simply append a string with other one but without space obviously.
To add space between two strings we can do something like this.
<?php
$string = 'Hello';
$string .= " World!";
echo $string;
?>