Are there specific PHP functions or methods that should be used to handle line breaks in text files?

When reading text files in PHP, it's important to handle line breaks correctly to ensure proper formatting and display of the text. One common approach is to use the `nl2br()` function, which converts newline characters to HTML line breaks. This function is useful when displaying text from a file on a webpage, as it preserves the line breaks in the original text.

// Read the contents of a text file
$file_contents = file_get_contents('example.txt');

// Convert newline characters to HTML line breaks
$file_contents = nl2br($file_contents);

// Output the formatted text
echo $file_contents;