How to use (.operator) In PHP
In PHP, the dot (.) operator is used for string concatenation. By placing the dot between strings and variables, they can be combined into a single string. This method provides a concise and efficient way to merge string elements.
Syntax
$string1 = "Hello";
$string2 = "world!";
$concatenatedString = $string1 . " " . $string2;
// Result: "Hello world!"
Alternatively, you can also use the .= operator to append one string to another, like so:
$string1 .= " world!";
// Result: "Hello world!"
How to Concatenate Strings in PHP ?
In PHP, strings can be concatenated using the( .
operator). Simply place the ” . "
between the strings you wish to concatenate, and PHP will merge them into a single string.
Contact Us