How can variables be properly written to a document in PHP?

To properly write variables to a document in PHP, you can use the concatenation operator (.) to combine strings and variables within the echo statement. This allows you to output the value of the variable alongside any other text or HTML elements in the document.

<?php
$variable = "Hello World!";
echo "The value of the variable is: " . $variable;
?>