PHP String Operators: Manipulating Strings in PHP
☰Fullscreen
Table of Content:
PHP has two operators that are specially designed for strings.
Operator | Name | Example | Result |
---|---|---|---|
. | Concatenation | $txt1 . $txt2 | Concatenation of $txt1 and $txt2 |
.= | Concatenation assignment | $txt1 .= $txt2 | Appends $txt2 to $txt1 |
Example: . Concatenation
Code:
Output:
The above code will produce the following result-
Happy Coding!
Example: .= Concatenation assignment
Code:
Output:
The above code will produce the following result-
Happy coding!!