How can you handle line breaks in PHP to ensure compatibility with different text editors like Wordpad and Notepad?

When handling line breaks in PHP to ensure compatibility with different text editors like Wordpad and Notepad, it's important to use the correct line break characters. Windows-based text editors like Wordpad and Notepad typically use the combination of carriage return (\r) and line feed (\n) characters for line breaks. To ensure compatibility, you can use the PHP `PHP_EOL` constant which represents the correct line break sequence for the current platform.

$text = "This is a sample text.";
$file = fopen("output.txt", "w");
fwrite($file, $text . PHP_EOL);
fclose($file);