<?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)
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
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.
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
29 Jul 2016
: This article mainly introduces the nginx http processing request entry. Students who are interested in PHP tutorials can refer to it.
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
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images