Hostname -d in PHP

There is a PHP function gethostname()

and php_uname('n')

, but both only return the hostname, not the domain name returned by the command hostname -d

.

Is there a native way that probably also works on Windows without running a new process to get this information?

+3


source to share


1 answer


My tests printed the FQDN of my host:

echo gethostbyaddr(gethostbynamel(gethostname())[0]);

      



I'm not sure what local DNS configuration is needed to reliably get the FQDN using this sequence of commands. However, you can try ...

0


source







All Articles