What is the best way to read a text file in PHP without losing formatting?
When reading a text file in PHP, it's important to use the correct function to preserve formatting. One way to achieve this is by using the `file_get_contents()` function, which reads the entire contents of a file into a string variable while maintaining the original formatting. This function is ideal for reading text files as it does not alter the content in any way.
$file_contents = file_get_contents('file.txt');
echo $file_contents;