php的异步http请求类
使用示例
如下,在request的时候能够定义请求完成之后的callback函数。
$base = event_base_new();
$uri = "http://www.baidu.com/";
$config = array(
'eventbase' => $base
);
for($i = 0; $i
$client = new AsyncHttpClient($uri, $config);
$client->request(function($result) {
echo "Result len:";
echo strlen($result['response']);
// parse response with Zend_Http_Response
$response = Zend_Http_Response::fromString($result['response']);
echo $response->getBody();
echo "\n";
});
}
event_base_loop($base);
echo "done\n";
?>
目前的实现比较初级,只做了get方法的封装,如果需要http上传或者post,还需要另外实现。另外这个类也需要php的libevent扩展。
Hot AI Tools
Undresser.AI Undress
AI-powered app for creating realistic nude photos
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undress AI Tool
Undress images for free
Clothoff.io
AI clothes remover
AI Hentai Generator
Generate AI Hentai for free.
Hot Article
Hot Tools
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
Hot Topics
1378
52
Base DEX Faucet: Aerodrome VS Curve
Mar 26, 2024 pm 04:31 PM
The Velodrome model is inspired by veCRV and aims to achieve superior consistency among the three key participants of DEX, including liquidity providers (LPs), token holders, and projects that require liquidity. However, many participants in the DeFi field still do not fully understand the underlying reasons. By reading this article in-depth, you will be able to get out of this dilemma and get to the bottom of it. Today we will discuss Velodrome/Aerodrome, a real success story in the DeFi field. This article will compare the two models and explain how Velodrome improves on the veCRV model and what significant impact these small differences have. First, let me state
Use regular expressions in golang to verify whether the input is a legal base64 string
Jun 24, 2023 am 10:01 AM
In Golang programming, it is a relatively common requirement to use regular expressions to verify whether the input is a legal base64 string. For developers, regular expressions can be used to quickly and accurately verify whether user input is correct. This article will introduce how to use regular expressions in Golang to verify whether the input is a legal base64 string. Starting with basic syntax In Golang, using regular expressions requires using the "regexp" library. This library provides "Compile" and "
Laravel Development: How to return a response using Laravel Response?
Jun 14, 2023 am 10:39 AM
Laravel is a popular PHP web development framework that provides many useful features and components, including response return. Response return is a very important concept in Laravel as it controls how the web application provides information to the client. In this article, we will detail the various ways Laravel responses are returned and how to use LaravelResponse to return responses. To return a string in Laravel, you can use the Response object
How to encode and decode using Base64 functions in Java
Jun 26, 2023 pm 02:24 PM
In Java programming, it is often necessary to convert binary data into text format for transmission, and Base64 encoding is a commonly used conversion method. Base64 converts three bytes of data into four bytes of text data. The text data consists of 64 characters. It only contains printable characters, so it can be transmitted in protocols such as emails and HTTP request messages. Java provides Base64 encoding and decoding APIs, so we can easily convert data. This article will introduce how to use in Java
Five selected Go language open source projects to take you to explore the technology world
Jan 30, 2024 am 09:08 AM
In today's era of rapid technological development, programming languages are springing up like mushrooms after a rain. One of the languages that has attracted much attention is the Go language, which is loved by many developers for its simplicity, efficiency, concurrency safety and other features. The Go language is known for its strong ecosystem with many excellent open source projects. This article will introduce five selected Go language open source projects and lead readers to explore the world of Go language open source projects. KubernetesKubernetes is an open source container orchestration engine for automated
Go language development essentials: 5 popular framework recommendations
Mar 24, 2024 pm 01:15 PM
"Go Language Development Essentials: 5 Popular Framework Recommendations" As a fast and efficient programming language, Go language is favored by more and more developers. In order to improve development efficiency and optimize code structure, many developers choose to use frameworks to quickly build applications. In the world of Go language, there are many excellent frameworks to choose from. This article will introduce 5 popular Go language frameworks and provide specific code examples to help readers better understand and use these frameworks. 1.GinGin is a lightweight web framework with fast
Base Dawgz ($DAWGZ) multichain token launched on decentralized exchanges today
Sep 06, 2024 am 06:34 AM
Base's first multichain token Base Dawgz ($DAWGZ) launched on decentralized exchanges today. $DAWGZ debuted on DEX at 18:00 CET and in its first
Detailed explanation of the role and usage of the echo keyword in PHP
Jun 28, 2023 pm 08:12 PM
Detailed explanation of the role and usage of the echo keyword in PHP PHP is a widely used server-side scripting language, which is widely used in web development. The echo keyword is a method used to output content in PHP. This article will introduce in detail the function and use of the echo keyword. Function: The main function of the echo keyword is to output content to the browser. In web development, we need to dynamically present data to the front-end page. At this time, we can use the echo keyword to output the data to the page. e


