What is the difference between $PHP_SELF and $_GET in PHP?

$PHP_SELF is a variable that contains the filename of the currently executing script, while $_GET is a superglobal array that is used to collect form data after submitting an HTML form with the method="get". $PHP_SELF can be vulnerable to cross-site scripting attacks if not properly sanitized, while $_GET values should always be sanitized before being used to prevent security risks.

// Using $_GET to collect form data and sanitize the input
$name = isset($_GET['name']) ? htmlspecialchars($_GET['name']) : '';
$email = isset($_GET['email']) ? filter_var($_GET['email'], FILTER_SANITIZE_EMAIL) : '';