PHP String operator

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PHP: String operator

String Operators

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

Example : PHP string concatenation operator

view plaincopy to clipboardprint?

  1. $x = "Good";  

  2. $y = $x ." Morning";  

  3. // now $y contains "Good Morning "  

  4. echo $y;  

  5. ?>  

Output :

Good Morning

View the example in the browser

Example : PHP string concatenating assignment operator

view plaincopy to clipboardprint?

  1. $x = "Good";  

  2. $x.= " Morning";  

  3. echo $x;  

  4. ?>  

Output

Good Morning