How can the presence of different line endings in source files affect the output in PHP?

The presence of different line endings in source files can affect the output in PHP by causing unexpected behavior or errors, especially when working on different operating systems. To solve this issue, it is recommended to standardize the line endings in your source files to a common format, such as using only one type of line ending (e.g., Unix LF or Windows CRLF).

// Standardize line endings to Unix LF format
$contents = file_get_contents('example.txt');
$contents = str_replace("\r\n", "\n", $contents);
file_put_contents('example.txt', $contents);