Home PHP Libraries Other libraries http request processing PHP class
http request processing PHP class
<?php
class cls_http_request
{
  public static function curl_get($url, $timeout = 1)
  {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
    $result = curl_exec($ch);
    curl_close($ch);
    if (is_string($result) && strlen($result))
    {
      return $result;
    }
    else
    {
      return false;
    }
  }

http request processing class (encapsulated based on CURL)

get method request (curl)

@param string $url requested url

@param integer $ timeout timeout time (s)

@return string(request successful) | false(request failed)



Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

PHP http request processing class PHP http request processing class

25 Jul 2016

PHP http request processing class

http request processing class http request processing class

25 Jul 2016

http request processing class

php http request class php http request class

02 May 2018

This article mainly introduces the HTTP request class of PHP, which has certain reference value. Now I share it with you. Friends in need can refer to it.

HTTP request and response processing in PHP HTTP request and response processing in PHP

23 May 2023

PHP is a scripting language commonly used for web development. In web development, the HTTP protocol is an important component. For PHP developers, knowing how to send HTTP requests and handle HTTP responses is one of the necessary skills. In this article, we will cover HTTP request and response handling in PHP. Sending HTTP requests In PHP, you can use curl or file_get_contents to send HTTP requests. 1.1curlcurl is a

PHP database processing encapsulation class PHP database processing encapsulation class

29 May 2018

This article mainly introduces the PHP database processing encapsulation class, and analyzes PHP's database connection, addition, deletion, modification and other operations based on mysqli encapsulation in the form of a complete example. Friends in need can refer to the following

nginx http processing request entry nginx http processing request entry

29 Jul 2016

: This article mainly introduces the nginx http processing request entry. Students who are interested in PHP tutorials can refer to it.

See all articles