How can PHP be used to output a text file from a server while maintaining proper indentation?

When outputting a text file from a server using PHP, it's important to maintain proper indentation to ensure readability. One way to achieve this is by using the PHP heredoc syntax, which allows for multi-line strings with proper indentation. By using heredoc syntax, you can easily output text content with consistent spacing and formatting.

<?php
$text = <<<EOT
    This is a sample text file output
    with proper indentation using heredoc syntax.
    You can easily maintain formatting and spacing
    by enclosing the text in <<<EOT ... EOT.
EOT;

header('Content-Type: text/plain');
echo $text;