PHP Basic
Introduction to PHP PHP Starting Requirements Downloading XAMPP Local Server PHP Variable Concept and Data Type PHP Coding Syntax Showing Output in PHP PHP String Concatenation Increment & Decrement in PHP PHP Logical Operator and Usage Part-1 PHP Logical Operator and Usage Part-2 PHP Comparison Operators Arithmetic and Assignment Operators PHP Switch Case Statement For loop in PHP Super Global Variable $_REQUEST and $_GET Part-1 String Length in PHP Function Declaration and UsageString concat is a system for adding two or more words with each other. This is most of the time used in several conditions like inside function or to store the value of two or more variables in a single variable. For better clearance we can give an example. Let's see a string variable given value
<?php
$data1 = 'Parrot is a cute bird';
?>
We have declared a variable $data1 that stores a string "Paroot is a cute bird". This is a single string. We now want to add a string "It has a big beak also" with $data1 so that we get a single string "Paroot is a cute bird. It has a big beak also". For doing this we need to use concate operator(.) So let's do this in the following code
<?php
$data1 = 'Parrot is a cute bird';
$data2 = "It has a big beak also";
$finaldata = $data1 . " . " . $data2;
echo $finaldata;
?>
Output:
Parrot is a cute bird . It has big beak also
The output of the data after concatenation will be "Parrot is a cute bird . It has big beak also" that is stored in variable $finaldata. We can also use .= sign to concat like below.
<?php
$data1 = 'Parrot is a cute bird';
$data2 = "It has a big beak also";
$data1 .= $data2;
echo $data1;
?>
This process will also give same data as output.
Parrot is a cute bird . It has big beak also
If you think you have query... then For contacting with us use Facebook . You can also use Github