What are the potential drawbacks of using file_get_contents to retrieve data in PHP, particularly in relation to formatting issues like line breaks?
When using file_get_contents to retrieve data in PHP, one potential drawback is that it reads the file as a string, which can cause formatting issues like missing line breaks. To solve this problem, you can use the nl2br() function to convert newline characters to HTML line breaks, ensuring that the formatting is preserved when displaying the content.
$file_contents = file_get_contents('example.txt');
$formatted_contents = nl2br($file_contents);
echo $formatted_contents;