JJG/Request.php
public function execute() {
    // Set a default latency value.
    $latency = 0;

    // Set up cURL options.
    $ch = curl_init();
    // If there are basic authentication credentials, use them.
    if (isset($this->userpwd)) {
      curl_setopt($ch, CURLOPT_USERPWD, $this->userpwd);
    }
    // If cookies are enabled, use them.
    if ($this->cookiesEnabled) {
      curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookiePath);
      curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookiePath);
    }
    // Send a custom request if set (instead of standard GET).
    if (isset($this->requestType)) {
      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->requestType);
      // If POST fields are given, and this is a POST request, add fields.
      if ($this->requestType == 'POST' && isset($this->postFields)) {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postFields);
      }
    }
    // Don't print the response; return it from curl_exec().
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_URL, $this->address);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
    curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
    // Follow redirects (maximum of 5).
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
    // SSL support.
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->ssl);
    // Set a custom UA string so people can identify our requests.
    curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
    // Output the header in the response.
    curl_setopt($ch, CURLOPT_HEADER, TRUE);
    $response = curl_exec($ch);
    $error = curl_error($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $time = curl_getinfo($ch, CURLINFO_TOTAL_TIME);
    curl_close($ch);

    // Set the header, response, error and http code.
    $this->responseHeader = substr($response, 0, $header_size);
    $this->responseBody = substr($response, $header_size);
    $this->error = $error;
    $this->httpCode = $http_code;

    // Convert the latency to ms.
    $this->latency = round($time * 1000);
  }
public function execute() {
    // Set a default latency value.
    $latency = 0;

    // Set up cURL options.
    $ch = curl_init();
    // If there are basic authentication credentials, use them.
    if (isset($this->userpwd)) {
      curl_setopt($ch, CURLOPT_USERPWD, $this->userpwd);
    }
    // If cookies are enabled, use them.
    if ($this->cookiesEnabled) {
      curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookiePath);
      curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookiePath);
    }
    // Send a custom request if set (instead of standard GET).
    if (isset($this->requestType)) {
      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->requestType);
      // If POST fields are given, and this is a POST request, add fields.
      if ($this->requestType == 'POST' && isset($this->postFields)) {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postFields);
      }
    }
    // Don't print the response; return it from curl_exec().
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_URL, $this->address);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
    curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
    // Follow redirects (maximum of 5).
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
    // SSL support.
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->ssl);
    // Set a custom UA string so people can identify our requests.
    curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
    // Output the header in the response.
    curl_setopt($ch, CURLOPT_HEADER, TRUE);
    $response = curl_exec($ch);
    $error = curl_error($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $time = curl_getinfo($ch, CURLINFO_TOTAL_TIME);
    curl_close($ch);

    // Set the header, response, error and http code.
    $this->responseHeader = substr($response, 0, $header_size);
    $this->responseBody = substr($response, $header_size);
    $this->error = $error;
    $this->httpCode = $http_code;

    // Convert the latency to ms.
    $this->latency = round($time * 1000);
  }
public function execute ( ) { // Set a default latency value. $ latency = 0 ; // Set up cURL options. $ ch = curl_init ( ) ; // If there are basic authentication credentials, use them. if ( isset ( $ this -> userpwd ) ) { curl_setopt ( $ ch , CURLOPT_USERPWD , $ this -> userpwd ) ; } // If cookies are enabled, use them. if ( $ this -> cookiesEnabled ) { curl_setopt ( $ ch , CURLOPT_COOKIEJAR , $ this -> cookiePath ) ; curl_setopt ( $ ch , CURLOPT_COOKIEFILE , $ this -> cookiePath ) ; } // Send a custom request if set (instead of standard GET). if ( isset ( $ this -> requestType ) ) { curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , $ this -> requestType ) ; // If POST fields are given, and this is a POST request, add fields. if ( $ this -> requestType == 'POST' && isset ( $ this -> postFields ) ) { curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ this -> postFields ) ; } } // Don't print the response; return it from curl_exec(). curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , TRUE ) ; curl_setopt ( $ ch , CURLOPT_URL , $ this -> address ) ; curl_setopt ( $ ch , CURLOPT_CONNECTTIMEOUT , $ this -> connectTimeout ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT , $ this -> timeout ) ; // Follow redirects (maximum of 5). curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , TRUE ) ; curl_setopt ( $ ch , CURLOPT_MAXREDIRS , 5 ) ; // SSL support. curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , $ this -> ssl ) ; // Set a custom UA string so people can identify our requests. curl_setopt ( $ ch , CURLOPT_USERAGENT , $ this -> userAgent ) ; // Output the header in the response. curl_setopt ( $ ch , CURLOPT_HEADER , TRUE ) ; $ response = curl_exec ( $ ch ) ; $ error = curl_error ( $ ch ) ; $ http_code = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; $ header_size = curl_getinfo ( $ ch , CURLINFO_HEADER_SIZE ) ; $ time = curl_getinfo ( $ ch , CURLINFO_TOTAL_TIME ) ; curl_close ( $ ch ) ; // Set the header, response, error and http code. $ this -> responseHeader = substr ( $ response , 0 , $ header_size ) ; $ this -> responseBody = substr ( $ response , $ header_size ) ; $ this -> error = $ error ; $ this -> httpCode = $ http_code ; // Convert the latency to ms. $ this -> latency = round ( $ time * 1000 ) ; }
Check a given address with cURL.

After this method is completed, the response body, headers, latency, etc.
will be populated, and can be accessed with the appropriate methods.
Check a given address with cURL .