Home Tutorial Php Phpbasics Tutorial PHP String Operator

 
 

PHP String Operator
Posted on: March 20, 2010 at 12:00 AM
Advertisement
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

Advertisement

Related Tags for PHP String Operator :


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: March 20, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com