w3resource

PHP: String operator

String Operators

There are two string operators : concatenation operator ('.') and concatenating assignment operator ('.=').

Example : PHP string concatenation operator

<?php
$x = "Good";
$y = $x ." Morning";
// now $y contains "Good Morning "
echo $y;
?>

Output:

Good Morning

View the example in the browser

Example: PHP string concatenating assignment operator

<?php
$x = "Good";
$x.= " Morning";
echo $x;
?>

Output

Good Morning

View the example of in the browser

Previous: Bitwise Operators
Next: Array Operators



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/php/operators/string-operators.php