'How to get hostname and local domain in php
I have a LAN app that runs in PHP7/Apache2
In order to more easily accommodate dynamic IP addressing, I need to switch it from relying on announcing (in it's communication with clients via xml) the the host IP address to computer hostname (this is the actual computer hostname) , and Lan extension (such as 'local' or 'lan'. example "Dell-Venue11.local.
I know I can use php's gethostname() command to get the host name but how do I get the LAN extension such as '.local' or '.lan'? It seems this extension is the tricky part of all this.
Because most alternatives that use IP addressing will use "127.0.0.1" when I try to run my php configuration pages by IP address from the same local machine (localhost). It seems I need to make sure the code either returns "hostname.ext" or the REAL IP address, even if the query comes from "localhost"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
