How does using $_SERVER['PHP_SELF'] differ from using $PHP_SELF in PHP scripts, and why is it recommended to use the former?

Using $_SERVER['PHP_SELF'] is recommended over using $PHP_SELF in PHP scripts because $_SERVER['PHP_SELF'] is a superglobal variable that provides a more secure and reliable way to get the current script filename. On the other hand, $PHP_SELF is a global variable that may not always be available or accurate, depending on the server configuration.

$script_name = $_SERVER['PHP_SELF'];
echo $script_name;