Getting fully qualified host name

From: Date: Mon, 07 Oct 2002 08:19:55 +0000
Subject: Getting fully qualified host name
Groups: php.general 
Request: Send a blank email to php-general+get-119049@lists.php.net to get a copy of this message
I need to get the fully qualified host name of the local machine, like "server.somewhere.com". Sounds simple, right? Seems not. I'm running a CLI script in PHP 4.3-cvs (on OpenBSD) so I have no HTTP or other global vars to look at, and it doesn't seem to be lying about in my environment (not that I want to rely on that anyway). The posix_uname command doesn't include the domain on non-GNU OSs. I can get the hostname, but not the domain. Can I get it through some other PHP command? I'd really prefer not to resort to platform-specifics like rummaging in /etc and parsing config files or doing something silly like a reverse DNS lookup... On some OS, this will give me the hostname: $hostname = /bin/hostname; However, it doesn't give me the domain, and it's highly platform specific (i.e. it won't work on Win). This seems like a pretty fundamental function that should be a built-in, but it doesn't seem to be possible to do this in a platform-independent way. Have I missed some php_fqdn() function? Any better ideas?

« previous php.general (#119049) next »