by @saigowthamr

How to concatenate the two strings in PHP

Home » php » How to concatenate the two strings in PHP

To concatenate the two strings we need to use period . concatenation operator in PHP.

Here is an example:

$first  = "hello ";
$second = "king";

$result = $first . $second ;

echo  $result

Output:

hello king

Similary, you can also use .= operator.

$name = "john ";

$name .= "james";

echo $name

Output:

john james

Best Web Development courses