Thursday 10 July 2014

How to concatenate two string / multiple strings in php

First We learn how to concatenate two string.  

$firststring="Hello ";  
$secondstring="New World";  
$final =$firststring. $secondstring;
echo $final; 
Output will be:
 Hello New World

Second We learn how to concatenate two Numbers.
 $firstno= 123;
 $secondno=567;
  $final =$firstno.$secondno;

 echo $final;
 Output will be:
 123567

Third We learn how to concatenate more than two strings.
 $firststring="Hello ";
 $secondstring="New World";
 $thirdstring ="My World";
$final =$firststring. $secondstring."and this is".$thirdstring;
 echo $final;
 Output will be:
 Hello New World and this is My World

 

 



No comments:

Post a Comment