Advertisement
Google Ad Slot: content-top
PHP Concatenate Strings
String concatenation is used to join two or more strings together into a single string. PHP provides the dot operator (.) for this purpose.
Example
<?php
$firstName = "John";
$lastName = "Doe";
// Concatenate strings using the . operator
$fullName = $firstName . " " . $lastName;
echo $fullName; // Outputs: John Doe
?>
An easier and better way is by using the power of double quotes.
By surrounding the two variables in double quotes with a white space between them, the white space will also be present in the result: