What are some best practices for handling line breaks in PHP when outputting data?

When outputting data in PHP, it's important to handle line breaks properly to ensure readability and consistency in the displayed content. One common approach is to use the PHP_EOL constant, which represents the correct end-of-line character for the current platform (e.g., "\n" for Unix-based systems and "\r\n" for Windows). By using PHP_EOL instead of hardcoding line break characters, you can ensure that your output is formatted correctly across different environments.

// Example of handling line breaks using PHP_EOL
$data = "First line" . PHP_EOL . "Second line" . PHP_EOL . "Third line";
echo $data;