How can the PHP script be modified to ensure compatibility with both PHP 4.3.8 and PHP 5 without compromising functionality?

To ensure compatibility with both PHP 4.3.8 and PHP 5 without compromising functionality, you can use conditional statements to check the PHP version and adjust the code accordingly. This can involve using alternative functions or syntax that are compatible with both versions.

if (version_compare(PHP_VERSION, '5.0.0', '>=')) {
    // PHP 5 compatible code
    echo "This is PHP 5 compatible code";
} else {
    // PHP 4 compatible code
    echo "This is PHP 4 compatible code";
}