How can the PHP code for a quote function be modified to allow quoting another quote?

When modifying the PHP code for a quote function to allow quoting another quote, we need to ensure that the nested quotes are properly escaped to avoid syntax errors. One way to achieve this is by using escape characters like backslashes before the inner quotes. This will allow the nested quotes to be treated as part of the string rather than the end of the string.

function quote($text) {
    return "\"$text\"";
}

// Example usage with nested quotes
echo quote("He said, \"She told me, 'Hello!'\"");