How can PHP developers secure their scripts when register globals is enabled?

When register globals is enabled in PHP, it allows user input to be automatically assigned to global variables, opening up security vulnerabilities such as injection attacks. To secure scripts in this scenario, developers should explicitly define and sanitize all variables used in their scripts.

// Disable register globals in PHP
if (ini_get('register_globals')) {
    foreach ($_REQUEST as $key => $value) {
        unset($$key);
    }
}