What are some best practices for adding elements to a string in PHP?

When adding elements to a string in PHP, it is best practice to use the concatenation operator (.) to append the new elements to the existing string. This ensures that the original string is not modified and a new string with the added elements is created. Additionally, using single quotes for the original string and double quotes for the elements being added can help improve readability and maintainability of the code.

// Original string
$originalString = 'Hello, ';

// Element to add
$newElement = 'World!';

// Concatenate the original string with the new element
$newString = $originalString . $newElement;

// Output the new string
echo $newString;