How can outdated PHP functions like "magic_quotes" be updated to modern standards in a codebase?

Outdated PHP functions like "magic_quotes" can be updated to modern standards by replacing them with more secure and up-to-date alternatives. One way to address this issue is to use functions like "addslashes" or prepared statements to properly escape user input and prevent SQL injection attacks.

// Replace magic_quotes with addslashes for escaping user input
if (get_magic_quotes_gpc()) {
    function stripslashes_deep($value) {
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
        return $value;
    }

    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
    $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}