String Operators
There are only two string operators in PHP: concatenation and shorthand concatenation . Both are shown in Table 6-3.
Table 6-3. The string operators
. |
Concatenation |
Returns the second value appended to the first: |
.= |
Shorthand concatenation |
Appends the second value to the first: |
These operators are used to join strings together, like this:
$first = "Hello, "; $second = "world!"; // join $first and $second; assign to $third $third = $first . $second; // $third is now "Hello, world!" $first .= " officer!"; // $first is now "Hello, officer!"
Get PHP in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.