'how to identify the web server name of remote host

According to this solution link it shows how to get the web server name for a local web server but how to do the same for a remote server by URL ?

i.e. $_SERVER['software'] returns name like Apache/2.2.21 (Win32) PHP/5.3.10

how can I apply this solution for a remote server - example here: http://browserspy.dk/webserver.php

I want to be able to specify the name of the remote server i.e. $url = 'www.domain.com'; - I want to get the web server name as shown above for host name specified in $url

I am only interested in the web server name

php


Solution 1:[1]

One method of doing this is using PHP's get_headers() function which return the web-servers response headers

$url = 'http://php.net';
print_r(get_headers($url));

which will return

Array
(
    [0] => HTTP/1.1 200 OK
    [1] => Server: nginx/1.6.2
    [2] => Date: Fri, 08 May 2015 13:21:44 GMT
    [3] => Content-Type: text/html; charset=utf-8
    [4] => Connection: close
    [5] => X-Powered-By: PHP/5.6.7-1
    [6] => Last-Modified: Fri, 08 May 2015 13:10:12 GMT
    [7] => Content-language: en
    [8] => X-Frame-Options: SAMEORIGIN
    [9] => Set-Cookie: COUNTRY=NA%2C95.77.98.186; expires=Fri, 15-May-2015 13:21:44 GMT; Max-Age=604800; path=/; domain=.php.net
    [10] => Set-Cookie: LAST_NEWS=1431091304; expires=Sat, 07-May-2016 13:21:44 GMT; Max-Age=31536000; path=/; domain=.php.net
    [11] => Link: <http://php.net/index>; rel=shorturl
    [12] => Vary: Accept-Encoding
)

as you can see you have the server header which tells you that they are running nginx/1.6.2

or you can add the second parameter to the function which will return the allready parsed headers

$url = 'http://php.net';
$headers = get_headers($url, true);
echo $headers['Server']; //ngnix/1.6.2

Solution 2:[2]

trainoasis is right, you can use :

$_SERVER['SERVER_SOFTWARE']

OR

$_SERVER['SERVER_SIGNATURE']

OR

gethostbyaddr($_SERVER['REMOTE_ADDR']);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2