Can the use of "CRLF line terminators" in PHP code lead to compatibility issues with different operating systems or text editors?
Using "CRLF line terminators" in PHP code can lead to compatibility issues with different operating systems or text editors because different systems interpret line endings differently. To ensure cross-platform compatibility, it's recommended to use only the "LF" line terminator. This can be achieved by using the PHP_EOL constant, which automatically outputs the correct line ending based on the operating system.
// Use PHP_EOL constant to ensure cross-platform compatibility
$file = fopen('example.txt', 'w');
fwrite($file, 'Hello' . PHP_EOL . 'World');
fclose($file);