On Thu, Nov 5, 2009 at 2:03 PM, Jim Lucas <lists@xxxxxxxxx> wrote: > Andrew Ballard wrote: >> I want to store the name of the computer that is executing a script in >> some log tables. (Our servers are load balanced, and I'd like to be >> able to determine which physical machine is serving each request.) >> >> On my development machine (Windows PC running the debugger in Zend >> Studio), I can find the name in three places: >> >> getenv('COMPUTERNAME') >> $_ENV['COMPUTERNAME'] >> $_SERVER['COMPUTERNAME'] >> >> On the development server, only the first works; $_ENV and $_SERVER >> both return NULL and throw an undefined index notice. >> >> I'm concerned about the reliability of all of these methods, since it >> seems that they are not always available and all three can be easily >> overridden inside a script. However, I notice that the header >> generated by phpinfo() remains correct even when I manually spoofed >> all three values on my development machine. Is there a reliable way to >> find this value? >> >> Andrew >> > > Well, I looked at all the variables that are available. Then I looked at the > data in the output of phpinfo(). > > The only place that I can find the information that you are looking for is > available in the "PHP Configuration" section and it is in the System information. > > So, looking at the phpinfo() page, I noticed the first comment down had a > method/function for converting the output of phpinfo() into a multidimensional > array. Taking the output of that users function, you can access the data the > data you are looking for. > > So, here is a link to the phpinfo() page. > > http://php.net/phpinfo > > From there, get the function called phpinfo_array() > > take the output of that and run it through the following set of commands. > > $data = phpinfo_array(TRUE); > list(, $server_name) = explode(' ', $data['PHP Configuration']['System']); > print( $server_name ); > > This will give you what you are looking for. > > Jim > Close, but not quite what I need. On the Windows systems, the System value is "Windows NT [hostname] [build]", so that just returns "NT". Thanks, though. :-) You never know when something like that might be useful. I found php_uname('n') which looks like it will return the information I'm after without having to dissect strings, and it appears to work just fine across platforms. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php