How can the $_SERVER superglobal variable be used to retrieve information about the script and HTML page names in PHP?

To retrieve information about the script and HTML page names in PHP, you can use the $_SERVER superglobal variable. The $_SERVER['SCRIPT_NAME'] element contains the path of the current script, while the $_SERVER['HTTP_HOST'] element contains the domain name of the server. Combining these values can give you the full URL of the current page.

$script_name = $_SERVER['SCRIPT_NAME'];
$html_page_name = basename($script_name);
echo "Script Name: $script_name <br>";
echo "HTML Page Name: $html_page_name";