Is there a way to retrieve current system fully qualified domain name using php-cli?
What I'm looking for is php function to retrieve the same thing that hostname -f is doing:
$ hostname -f #returns needed: system01.dev.lan
I tried following:
php_uname('n') // returns: system01
gethostname() // returns: system01
gethostbyname(gethostname()) // returns ip address
gethostbyname(gethostname() . '.') // returns system01
$_SERVER dose not exist (because only cli env)
Again, I know I can do this
php -r "var_dump(shell_exec('hostname -f'));"
But for this trivial task, I think php should have built in functionality to retreive fqdn.
gethostbyaddr(gethostbyname(gethostname()));
This returns the FQDN for me while everything else just returns localhost or hostname.