What is the difference between using "global" and accessing variables directly from $_GET in PHP?

Using "global" in PHP allows you to access variables from the global scope within a function. However, directly accessing variables from $_GET can pose security risks, as it exposes user input directly to your code without proper filtering or validation. It is recommended to use filter_input() function to access and sanitize input from $_GET to prevent vulnerabilities such as SQL injection or cross-site scripting attacks.

// Using filter_input to access and sanitize input from $_GET
$variable = filter_input(INPUT_GET, 'variable', FILTER_SANITIZE_STRING);