$hostname = get_hostname(); echo "Server hostname is: " . $hostname;
$hostname = get_hostname(); if ($hostname == "localhost") { echo "Welcome to the localhost!"; } else { echo "Welcome to our website!"; }This code checks if the server's hostname is "localhost" and welcomes the user accordingly. If it's anything else, it will welcome the user to the website. The get_hostname function is a part of the PHP Core package and does not require any external library or package.