append a string to the end of another string in php

To append a string to the end of another string in PHP, you can use the concatenation operator (.) or the shorthand assignment operator (.=) to add the new string to the end of the original string.

Example using concatenation operator:

main.php
$original_string = "Hello, ";
$new_string = "world!";
$full_string = $original_string . $new_string;
echo $full_string; // outputs "Hello, world!"
147 chars
5 lines

Example using shorthand assignment operator:

main.php
$original_string = "Hello, ";
$new_string = "world!";
$original_string .= $new_string;
echo $original_string; // outputs "Hello, world!"
137 chars
5 lines

In both cases, the resulting string is "Hello, world!", which is the original string with the new string appended to the end.

gistlibby LogSnag