How can one ensure cross-platform compatibility when dealing with line endings in PHP string manipulation?

To ensure cross-platform compatibility when dealing with line endings in PHP string manipulation, it is recommended to use the PHP_EOL constant instead of hardcoded line endings like "\n" or "\r\n". This constant represents the correct line ending for the current platform, making your code work seamlessly on different operating systems.

// Example of using PHP_EOL for cross-platform compatibility
$string = "Hello" . PHP_EOL . "World";
echo $string;