To find the current hostname in PHP, you can use the $_SERVER['HTTP_HOST']
variable. This variable contains the hostname from the current request headers.
Here's an example code snippet:
main.php80 chars3 lines
This will output something like:
main.php33 chars2 lines
Note that the $_SERVER
variable is an array that contains various server and execution environment information, so be sure to sanitize and validate any user input that is derived from it.
gistlibby LogSnag