Free Beginner PHP Tutorials - String Concatenation
2016:09:26 / Science and Tutorials
Learn how to concatenate two strings or variables together with dot operator in PHP. See example:-
String concatenation in PHP
String concatenation is combining two or more strings value to form one string value.
In PHP, this is achieved by using dot operator (.) and the concatenating assignment operator ('.='). The dot concatenation operator returns the concatenation of its right and left arguments while the concatenation assignment operator appends the argument on the right side to the argument on the left side.
<?php $a = "Hello "; $b = $a . "World!"; // $b contains "Hello World!" $a = "Hello "; $a .= "World!"; // $a contains "Hello World!" ?>