Home Tutorial Php PHP Variables Concatenate

 
 

Share on Google+Share on Google+
PHP Variables Concatenate
Posted on: January 11, 2010 at 12:00 AM
Advertisement
PHP Concatenate Variable - When we have more than one variable and we want to use those variable in one line or paragraph then we used the concatenate variables in php to compile them.

PHP Variables Concatenate
When we have more than one variable and we want to use those variable in one line or paragraph then we used the concatenate variables in php to compile them. In other words, it is used when we need to print more than one string where we have other variables or other things as well. The . operator is the string concatenation operator and is very useful for situations where you have too many variables and you want to compile in one. Let see the example :

<?php

$name = "Suraj Mittal";

$age = "22";

echo $name ."is the employee of Rose India ".$age." years old";

?>

 


The output is: Suraj Mittal is the employee of Rose India 22 years old, getting Rs. 15000 every month and his Employee Id is 12.
Here, in the above example we have more than one variables and we want to show in one line. For this purpose we used concatenate (dot) to compile both of them in one line. You could also write the statement above like that without string concatenating but I think you don't want to write the same code again and again. PHP has a nice way of doing this for you, string concatenating.

Advertisement

Related Tags for PHP Variables Concatenate:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 11, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com