note 29577 deleted from function.fsockopen by bjori

From: Date: Tue, 03 Apr 2007 11:17:20 +0000
Subject: note 29577 deleted from function.fsockopen by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-125030@lists.php.net to get a copy of this message
Note Submitter: matthijs at rohs dot nl ---- Here's a function that finds the Server Software of a server and returns it. The timeout is at 1 second, but I would prefer, if you use this function many times on a page, to set it lower. <?php function get_server_software($domain) { $fp = fsockopen($domain, 80, $errno, $errstr, 1); if (!$fp) { return(""); } else { fputs($fp, "HEAD / HTTP/1.1\r\nHost: " . $domain . "\r\n\r\n"); while (!feof($fp)) { if (preg_match("/\bServer:/", $server = fgets($fp, 256))) { fclose($fp); return(substr($server, 8, -2)); } } fclose($fp); } } ?>

« previous php.notes (#125030) next »