RE: [PHP] Getting fully qualified host name

From: Date: Tue, 08 Oct 2002 01:14:31 +0000
Subject: RE: [PHP] Getting fully qualified host name
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-119176@lists.php.net to get a copy of this message
If you happen to be running *nix (which it sounds like you are) and want to compile the Pwee extension into PHP you can have access to constants like SERVER_HOSTNAME. http://pwee.sourceforge.net Lance > -----Original Message----- > From: Spongle [mailto:vlcc69jfbo001@sneakemail.com] > Sent: Monday, October 07, 2002 4:20 AM > To: php-general@lists.php.net > Subject: [PHP] Getting fully qualified host name > > > 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? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#119176) next »