What potential issues can arise when trying to retrieve the name of the script using $_SERVER['QUERY_STRING'] in PHP?

Using $_SERVER['QUERY_STRING'] in PHP to retrieve the name of the script can lead to potential security vulnerabilities, as it exposes the script name to the user. It is recommended to use $_SERVER['SCRIPT_NAME'] instead, as it provides the actual path to the script without exposing sensitive information.

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