How To Append a string in PHP

How To append a String in PHP

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.

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;
?>

Demo

Comments

Popular posts from this blog

Gove confirms mandatory housebuilding targets for councils will be abolished in face of Tory rebellion – UK politics live

Kotak Mahindra Bank Recruitment 2022 Released for Graduate Candidates And Apply Online