how can this be done in PHP
curl -I http://www.google.com | grep "Server:"
and is it possible to just echo OS like Linux Or windows of site , like web server is echoed using curl
My Try
<?
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,"http://google.com");
curl_setopt ($ch, CURLOPT_HEADER, 1);
$data = curl_exec ($ch);
curl_close ($ch);
echo $data ;
?>
Basically this is an extract from the Horde_Http library. Specifically the Curl request and the Curl response handlers.
It is somewhat more complex than what you did with your “grep” command but it looked as though you want to analyse the response headers. That is why I left the somewhat more complex header analysis in the code.