boss420/common

PHP开发者的通用库...

v1.5.4 2017-06-15 16:22 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:14:31 UTC


README

一些重要的通用库,如异步处理、加密等...

GitHub:https://github.com/boss420/Common

## 安装 GitHub

git clone https://github.com/boss420/Common.git

或者您可以使用 composer

composer require boss420/common

## 使用

### AsynHandle

使用多进程模拟多线程。

$oop = new \boss420\common\AsynHandle();
$result = $oop->Request("xxxxxx");
echo $result;

代码将很快返回,结果只显示代码是否正常工作。您无法从这段代码中获取响应,因为实际的URL请求仍然会在后端处理。

因此,您可以轻松地向多个URL发送多个请求,而无需等待处理结果。

该方法还包含一些默认参数,您可以更改为您所需的参数。

 public function Request($url, $cookie = array(), $post = array(), $timeout = 3){
 //***
 }

此外,AsynHandle 还包含一个同步请求方法称为 Get,调用此方法后,您可以获取真实的响应。

### 示例代码

header('Content-type: application/json');
require_once "../src/AsynHandle.php";
$oop = new \boss420\common\AsynHandle();
$result = $oop->Get("https://www.udopay.com/index.php/Gateway/securepay");
echo $result;

此方法也包含一些默认参数,它们很容易理解。

 public function Get($url, $cookie = array(), $post = array(), $timeout = 30){
 //***
 }