Concatenate two variables or strings – PHP

Hi Friends,
The DOT(.) operator is used to concatenate two variable or string in PHP. The ‘.’ operator which returns the concatenation of its right and left string.
eg:



And also ‘.=’ operator used append the arguments on the right side to the left side arguments.
eg:




Example 1



 
';
echo "hello". "World";
echo '
'; // Output: helloworld $a1 = "Hello "; $a1 .= "World!"; // now $a1 contains "Hello World!" echo $a1; echo "hi". "welcome"; ?>





Example 2

 ';
echo'this is ', $a ,' and ', $b;  //output: this is hello and world
echo "
"; echo"this is $a and $b"; // Output:this is hello and world ?>





COMMA is not concatenating it just used to echo one by one and in that way complete string appears together.In javascript PLUS(+) is used as concatenation operator.

If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

One thought on “Concatenate two variables or strings – PHP

  1. warm blankets

    Hello! Do you know if they make any plugins to assist with SEO?
    I’m trying to get my blog to rank for some targeted keywords but I’m not seeing
    very good gains. If you know of any please share. Thanks!
    I saw similar art here: Eco product

Leave a Reply

Your email address will not be published.