There's really only one string operator, and that's the concatenation operator . (dot).
This operator takes two string values, and joins the right-hand string onto the left-hand one to make a longer string.
<?php echo "a, " . "b"; // Displays "a, b" ?>/*ww w . ja v a2 s . c om*/
You can concatenate more than two strings at once.
The values you concatenate don't have to be strings.
Due to PHP's automatic type conversion, non-string values, such as integers and floats, are converted to strings at the time they're concatenated:
Code: <?php $tempF = 1; echo "this is " . ( (5/9) * ($tempF-32) ) . " degrees C."; ?>
You can use the combined assignment operator .= to join a new string onto the end of an existing string variable.
For example, the following two lines of code both do the same thing.
They change the string variable $x by adding the string variable $y to the end of it:
$x = $x . $y; $x .= $y;