Home Tutorial Php Phpbasics Tutorial PHP String Operator

 
 

PHP String Operator
Posted on: March 20, 2010 at 12:00 AM
In this tutorial we will study about string operator, string operators work only on the strings and there are only two kinds of operators are available in PHP "." and ".=", Examples in this tutorial will make it more clear.

String Operator:

In PHP there are only two operators are available for strings, first one is "." operator, and another is ".= " operator. Basically both does the same but with a little difference.

First operator concatenates the first value/variable with the next one and second operator appends the argument on the right side to left side of the operator.

Example:

<?php

$a="rose";

echo "Value of a is =". $a."<br/>";

$a.="india";

echo "After concatenation:<br/>";

echo "Value of a is =". $a;

?>

Output:

Value of a is =rose
After concatenation:
Value of a is =roseindia

Example:

<?php

$a="rose";

$b="india";

echo $a.$b;

?>

Output:

roseindia

Example:

<?php

echo "rose"."india";

?>

Output:

roseindia

Related Tags for PHP String Operator :


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.