Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7419669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:06:38+00:00 2026-05-29T08:06:38+00:00

how can this be done in PHP curl -I http://www.google.com | grep Server: and

  • 0

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  ;

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:06:39+00:00Added an answer on May 29, 2026 at 8:06 am
    <?php
    // create a new cURL resource                                                                                                                                
    $ch = curl_init();
    
    // set URL and other appropriate options                                                                                                                     
    curl_setopt($ch, CURLOPT_URL, "http://www.google.com/");
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    // grab URL and pass it to the browser                                                                                                                       
    $result = curl_exec($ch);
    
    /* Curl returns multiple headers, if the last action required multiple                                                                                       
     * requests, e.g. when doing Digest authentication. Only parse the                                                                                           
     * headers of the latest response. */
    preg_match_all('/(^|\r\n\r\n)(HTTP\/)/', $result, $matches, PREG_OFFSET_CAPTURE);
    $startOfHeaders = $matches[2][count($matches[2]) - 1][1];
    $endOfHeaders = strpos($result, "\r\n\r\n", $startOfHeaders);
    $headers = substr($result, $startOfHeaders, $endOfHeaders - $startOfHeaders);
    $headers = preg_split("/\r?\n/", $headers);
    foreach ($headers as $headerLine) {
      if (preg_match('|^Server:\s+(.+)|', $headerLine, $m)) {
        var_dump($m[1]);
      }
    }
    
    // close cURL resource, and free up system resources                                                                                                         
    curl_close($ch);
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can this be done? It seems like this should be possible. In general, I
Can this be done in 1 line with PHP? Would be awesome if it
Possible Duplicate: PHP Curl script to pull data from remote server every 10 minutes
i don't know if this can be done using php but it would be
Can this be done - opening a variable with one PHP tag, then closing
I have made something just like this using php and mysql. Just curious to
So I have a link like this: <a href=http://thissite.org/thisfolder/21/thispage.php> What I want to do
Can this be done by setting a property? I'd prefer that approach then to
Can this be done w/ linqtosql? SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime FROM Incidents GROUP
Can this be done in JavaScript? type == 1 ? function1() : function2();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.