<?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

28 Oct 2024
Properly Closing an HTTP Request for Background ProcessingIn HTTP requests, it is often desirable to respond immediately while processing the...

20 Nov 2024
Terminating HTTP Request ProcessingWhen serving HTTP requests, there may be scenarios where it becomes necessary to terminate the processing and...

31 Oct 2024
HTTP Request Handling: Closing Properly and Background ProcessingWhen processing incoming HTTP requests, you may face a scenario where you need to...

29 Oct 2024
How to Properly Close a Request for Background ProcessingIntroductionWhen responding to HTTP requests, you may need to process the payload in the...

13 Dec 2024
Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

17 Apr 2025
I encountered a tricky problem when developing a project that needs to handle a large number of HTTP requests and responses: PHP's native HTTP handling is too cumbersome and inconsistent, making the code difficult to maintain and scale. After trying multiple methods, I found that the sabre/http library provides a simple and powerful solution that greatly simplifies the processing of HTTP requests and responses, making my project more efficient and maintainable.


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
