Wednesday, April 18, 2012

Using Concatenation Operator

Now we are talking about Concatenation.
Concatenation operator (.) [dot] is use to put two string value together.
To concatenate two string value together, use the concatenation operator.      

++++++++++++++++++
<?php
$string1="Hello";
$string2="Welcome to Mint PHP !";
echo $string1. " " .$string2;
?>
++++++++++++++++++
Output:
___________

Hello Welcome to Mint PHP !
______________

There is another method, without using the   .= operator  by this we can join different variable into another variable.
Example:
++++++++++++++++


   <?php
$string1="Hello,";
$string2="World!";
$string3=$string1 . $string2; 
$string4=$string1 . ' and welcome to Mint PHP Blog ' .$string2;

echo $string3.' ' .$string4;

?>

++++++++++++++
Output:
_______

Hello,World! Hello, and welcome to Mint PHP Blog World!
_____________