PHP Concatenation


php PHP Concatenation PHP Tutorials

Concept of concatenation and PHP concatenation

Concatenation is process of joining the entities . We can concatenate on left and right side of any variable or with any string. Suppose we have two words in two different variables . Then we can concatenate them into the third variable . Then third variable will have the joined or total data that is gained by joining the two variables. A simple example is : For example, "infrastructure" is a concatenation of the words "infra" and "structure" into a new word.

Concatenation of two variables

In PHP for concatenation we use the dot ( . ) symbol . Below two variables are concatenate using dot symbol . <?php $var_a = "Hello to the"; $var_a = "Future !"; $result = $var_a.$var_b; echo $result; ?>Output: Hello to the Future !

Concatenation of group of string with variables

We can also concatenate strings with the variable. <?php $figure= "67"; $result = "By BuiltWith report 2018 " .$figure." % web based projects developed in PHP"; echo $result; ?>Output: By BuiltWith report 2018 67 % web based projects developed in PHP

php PHP Tutorials Chapter Next »