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



PHP: Tips of the Day

$GLOBALS: This SuperGlobal Variable is used for accessing globals variables

Example:

<?php
$x = 25;
function foo(){
 echo $GLOBALS['x'];
}
echo $GLOBALS['x'];

?>

Output:

25