Concatenation Operators

<?php

$firstName=”Virat”;

$leatName=” Kohali”;

         echo $firstName.” “.$lastName;  // Output : Virat Kohali

?>

Here in this PHP code, you can see two red color dot symbol, we call as concatenation operators. Using this concatenation operator we can print the two variable value in one echo statement as shown in the code.

Concatenation Assignment

<?php

$message=“Hello,”;

$message.=” Learning PHP code is to easy”;

echo $message; // Output : Hello, Learning PHP code is to easy

?>

Using concatenation assignment you can append the variable value, show as above code. In this code first $message with only equal sing and second with concatenation operator

Concatenation Tip 

  • Mostly use for combine and append string in variable
  • You can use HTML code also

Next var_dump()