⊗ppPmBsSC 28 of 447 menu

String Concatenation in PHP

For string addition (concatenation) the dot operator is used:

<?php $str = 'abc' . 'def'; // add two strings echo $str; // will output 'abcdef' ?>

Strings can also be stored in variables:

<?php $str1 = 'abc'; $str2 = 'def'; echo $str1 . $str2; // will output 'abcdef' ?>

You can also add variables and strings:

<?php $str1 = 'abc'; $str2 = 'def'; echo $str1 . '!!!' . $str2; // will output 'abc!!!def' ?>

Create a variable $str and assign it the string 'hello'. Output the value of this variable to the screen.

Create a variable with the text 'abc' and a variable with the text 'def'. Using these variables and the string concatenation operation, output the string 'abcdef' to the screen.

byenru