Tools
in
网络请求支持 Class Tools
Table of Contents
$cache_path | 缓存路径 | null |
---|---|---|
$cache_callable | 缓存写入操作 | array |
$cache_curl | 网络缓存 | array |
createNoncestr() | 产生随机字符串 | string |
getExtMine() | 根据文件后缀获取文件类型 | string |
getMines() | 获取所有文件扩展的类型 | array |
createCurlFile() | 创建CURL文件对象 | CURLFile|string |
arr2xml() | 数组转XML内容 | string |
_arr2xml() | XML内容生成 | string |
xml2arr() | 解析XML内容到数组 | array |
arr2json() | 数组转xml内容 | null|string |
buildEnEmojiData() | 数组对象Emoji编译处理 | array |
buildDeEmojiData() | 数组对象Emoji反解析处理 | array |
emojiEncode() | Emoji原形转换为String | string |
emojiDecode() | Emoji字符串转换为原形 | string |
json2arr() | 解析JSON内容到数组 | array |
get() | 以get访问模拟访问 | bool|string |
post() | 以post访问模拟访问 | bool|string |
doRequest() | CURL模拟网络请求 | bool|string |
_buildHttpData() | POST数据过滤处理 | array|string |
pushFile() | 写入文件 | string |
setCache() | 缓存配置与存储 | string |
getCache() | 获取缓存内容 | null|mixed |
delCache() | 移除缓存文件 | bool |
_getCacheName() | 应用缓存目录 | string |
Properties
$cache_path
缓存路径
public
static null
$cache_path
= null
$cache_callable
缓存写入操作
public
static array
$cache_callable
= [
'set' => null,
// 写入缓存
'get' => null,
// 获取缓存
'del' => null,
// 删除缓存
'put' => null,
]
$cache_curl
网络缓存
private
static array
$cache_curl
= []
Methods
createNoncestr()
产生随机字符串
public
static createNoncestr(
[ $length :
int
= 32 ]
[, $str :
string
= "" ]
)
: string
Parameters
- $length : int = 32
指定字符长度
- $str : string = ""
字符串前缀
Return values
stringgetExtMine()
根据文件后缀获取文件类型
public
static getExtMine(
$ext :
string|array
[, $mine :
array
= [] ]
)
: string
Parameters
- $ext : string|array
文件后缀
- $mine : array = []
文件后缀MINE信息
Tags
Return values
stringgetMines()
获取所有文件扩展的类型
private
static getMines(
)
: array
Tags
Return values
arraycreateCurlFile()
创建CURL文件对象
public
static createCurlFile(
$filename :
[, $mimetype :
string
= null ]
[, $postname :
string
= null ]
)
: CURLFile|string
Parameters
Tags
Return values
CURLFile|stringarr2xml()
数组转XML内容
public
static arr2xml(
$data :
array
)
: string
Parameters
- $data : array
Return values
string_arr2xml()
XML内容生成
private
static _arr2xml(
$data :
array
[, $content :
string
= '' ]
)
: string
Parameters
- $data : array
数据
- $content : string = ''
Return values
stringxml2arr()
解析XML内容到数组
public
static xml2arr(
$xml :
string
)
: array
Parameters
- $xml : string
Return values
arrayarr2json()
数组转xml内容
public
static arr2json(
$data :
array
)
: null|string
Parameters
- $data : array
Return values
null|stringbuildEnEmojiData()
数组对象Emoji编译处理
public
static buildEnEmojiData(
$data :
array
)
: array
Parameters
- $data : array
Return values
arraybuildDeEmojiData()
数组对象Emoji反解析处理
public
static buildDeEmojiData(
$data :
array
)
: array
Parameters
- $data : array
Return values
arrayemojiEncode()
Emoji原形转换为String
public
static emojiEncode(
$content :
string
)
: string
Parameters
- $content : string
Return values
stringemojiDecode()
Emoji字符串转换为原形
public
static emojiDecode(
$content :
string
)
: string
Parameters
- $content : string
Return values
stringjson2arr()
解析JSON内容到数组
public
static json2arr(
$json :
string
)
: array
Parameters
- $json : string
Tags
Return values
arrayget()
以get访问模拟访问
public
static get(
$url :
string
[, $query :
array
= [] ]
[, $options :
array
= [] ]
)
: bool|string
Parameters
- $url : string
访问URL
- $query : array = []
GET数
- $options : array = []
Tags
Return values
bool|stringpost()
以post访问模拟访问
public
static post(
$url :
string
[, $data :
array
= [] ]
[, $options :
array
= [] ]
)
: bool|string
Parameters
- $url : string
访问URL
- $data : array = []
POST数据
- $options : array = []
Tags
Return values
bool|stringdoRequest()
CURL模拟网络请求
public
static doRequest(
$method :
string
, $url :
string
[, $options :
array
= [] ]
)
: bool|string
Parameters
- $method : string
请求方法
- $url : string
请求方法
- $options : array = []
请求参数[headers,data,ssl_cer,ssl_key]
Tags
Return values
bool|string_buildHttpData()
POST数据过滤处理
private
static _buildHttpData(
$data :
array
[, $build :
bool
= true ]
)
: array|string
Parameters
- $data : array
需要处理的数据
- $build : bool = true
是否编译数据
Tags
Return values
array|stringpushFile()
写入文件
public
static pushFile(
$name :
string
, $content :
string
)
: string
Parameters
- $name : string
文件名称
- $content : string
文件内容
Tags
Return values
stringsetCache()
缓存配置与存储
public
static setCache(
$name :
string
[, $value :
string
= '' ]
[, $expired :
int
= 3600 ]
)
: string
Parameters
- $name : string
缓存名称
- $value : string = ''
缓存内容
- $expired : int = 3600
缓存时间(0表示永久缓存)
Tags
Return values
stringgetCache()
获取缓存内容
public
static getCache(
$name :
string
)
: null|mixed
Parameters
- $name : string
缓存名称
Return values
null|mixeddelCache()
移除缓存文件
public
static delCache(
$name :
string
)
: bool
Parameters
- $name : string
缓存名称
Return values
bool_getCacheName()
应用缓存目录
private
static _getCacheName(
$name :
string
)
: string
Parameters
- $name : string