FizeMisc参考手册

欢迎使用

欢迎使用

FizeMisc 是对一些常用的系统内置函数进行面向对象的再封装类库,方便调用。 FizeMisc 是 Fize 项目族群的底层依赖,众多 Fize 项目依赖 FizeMisc ,同时欢迎您使用 Fize。 如果你钟爱 OOP (面向对象),那 FizeMisc 更不容错误!事实上,Fize项目是完全面向对象的,绝对适合处女座的强迫症患者! FizeMisc 有非常完善的参考文档,其代码结构也经过精雕细琢,精炼而实用。

注解

FizeMisc 是不依赖于其他外部函数、外部类库的独立类库,同时 FizeMisc 会根据实际情况添加、删除类库。 使用composer的波浪线(~)版本限定方法可以让您保持绝对安全的调用环境依赖。

类库参考

目前 FizeMisc 已有的类包括如下:

安装说明

安装说明

FizeMisc 的环境要求如下:

  • “php”: “>=5.4.0”
  • 如果使用 Bz2 ,请开启bz2扩展
  • 如果使用 Iconv ,请开启iconv扩展
  • 如果使用 MbString ,请开启mbstring扩展

使用Composer安装

FizeMisc 支持使用 Composer 安装,也是唯一官方推荐的安装方法。

注解

如果您尚未安装 composer ,请参考 安装 composer

使用 阿里云镜像 以提高下载速度及稳定性。

在命令行下面,切换到您的项目根目录下面并执行下面的命令:

composer require fize/misc

好了!一步到位,您现在可以开始使用 FizeMisc 了,就是这么简单!~

注解

Fize 项目(包括所有子项目)严格遵守 语义化版本 ,您可以放心大胆的使用。

更新日志

更新日志

  • v0.1.0 (2019-11-18) : 移除一些暂未实现的类
  • v0.0.1 (2019-10-08) : 初始版本发布。

许可协议

许可协议

The MIT License (MIT)

Copyright (c) 2014 - 2019, British Columbia Institute of Technology

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

注解

以下为中文译文

MIT 开源许可协议

版权所有 (c) 2014 - 2019, 不列颠哥伦比亚理工学院

特此向任何得到本软件副本或相关文档的人授权: 被授权人有权使用、复制、修改、 合并、出版、发布、散布、再授权和/或贩售软件及软件的副本, 及授予被供应人 同等权利,只需服从以下义务:

在软件和软件的所有副本中都必须包含以上版权声明和本许可声明。

该软件是”按原样”提供的,没有任何形式的明示或暗示,包括但不限于为特定目的和不侵权的适销性和适用性的保证担保。 在任何情况下,作者或版权持有人,都无权要求 任何索赔,或有关损害赔偿的其他责任。 无论在本软件的使用上或其他买卖交易中, 是否涉及合同,侵权或其他行为。

捐赠我们

捐赠我们

Fize 项目及其下所有子项目目前都为个人维护,坚持开源和免费提供使用。 如果您对我们的成果表示认同并且觉得对你有所帮助我们愿意接受来自各方面的捐赠。

使用手机支付宝扫描进行捐赠

https://i.loli.net/2019/11/19/MY9pe7vIb1rUGf4.jpg

使用手机微信扫描进行捐赠

https://i.loli.net/2019/11/19/wGWiC6mEr1MTD9K.jpg

以下是捐赠明细(截止2019-11-19):

  • 梁*萍 50.00元
  • 董*辉 100.00元
  • 曾*庆 20.00元
  • 许*钦 10.00元
  • 陈* 88.88元

类库参考

类库参考

bzip2 压缩包操作类

属性
命名空间 fize\misc
类名 Bz2
方法:
方法名 说明
__construct() 构造
__destruct() 析构函数
close() 关闭 bzip2 文件
compress() 把一个字符串压缩成 bzip2 编码数据
decompress() 解压经 bzip2 编码过的数据
errno() 返回一个 bzip2 错误码
error() 返回包含 bzip2 错误号和错误字符串的一个数组
errstr() 返回一个 bzip2 的错误字符串
flush() 强制写入所有写缓冲区的数据
open() 打开一个经 bzip2 压缩过的文件
read() 从文件读取数据
write() 二进制安全地写入 bzip2 文件
方法
__construct()

构造

public function __construct (

    string $file,

    string $mode

)
参数:
名称 说明
file 待打开的文件的文件名,或者已经存在的资源流。
mode 模式
参数 `$file` :
  指定文件不存在时将尝试创建
参数 `$mode` :
   fopen() 函数类似,但仅仅支持 'r'(读)和 'w'(写)。
__destruct()

析构函数

public function __destruct ()
close()

关闭 bzip2 文件

public function close () : bool
compress()

把一个字符串压缩成 bzip2 编码数据

public static function compress (

    string $source,

    int $blocksize = 4,

    int $workfactor = 0

) : string
参数:
名称 说明
source 待压缩的字符串。
blocksize 指定压缩时使用的块大小
workfactor 控制压缩阶段出现最坏的重复性高的情况下输入数据时的行为
返回值:

压缩后的字符串

参数 `$blocksize` :
  应该是一个 1-9 的数字。9 可以有最高的压缩比,但会使用更多的资源。
参数 `$workfactor` :
  值可以是在 0  250 之间,0 是一个特殊的情况。
decompress()

解压经 bzip2 编码过的数据

public static function decompress (

    string $source,

    int $small = 0

) : string
参数:
名称 说明
source 编码过的数据
small 是否使用一种内存开销更小的替代算法
返回值:

解压后的字符串

errno()

返回一个 bzip2 错误码

public function errno () : int
error()

返回包含 bzip2 错误号和错误字符串的一个数组

public function error () : array
errstr()

返回一个 bzip2 的错误字符串

public function errstr () : string
flush()

强制写入所有写缓冲区的数据

public function flush () : bool
返回值:成功时返回 TRUE, 或者在失败时返回 FALSE。
open()

打开一个经 bzip2 压缩过的文件

public function open (

    string $file,

    string $mode

)
参数:
名称 说明
file 待打开的文件
mode 模式
参数 `$mode` :
 `fopen()` 函数类似,但仅仅支持 'r'(读)和 'w'(写)。
其他任何模式都会导致 bzopen 返回 FALSE
read()

从文件读取数据

public function read (

    int $length = 1024

) : string
参数:
名称 说明
length 读取字节长度
返回值:

返回解压的数据

参数 `$length` :
读取到 length(未经压缩的长度)个字节,或者到文件尾,取决于先到哪个。
如果没有提供该参数, read()  方法一次会读入 1024 个字节(未经压缩的长度)。
一次最大可读入 8192 个未压缩的字节。
write()

二进制安全地写入 bzip2 文件

public function write (

    string $data,

    int $length = null

) : int
参数:
名称 说明
data 要写入的数据
length 写入字节长度
返回值:

返回写入的数据字节数

注意不能多次调用该方法,bz2文件是一次性写入并覆盖的
参数 `$length` :
  如果提供了参数 `$length` ,将仅仅写入 length(未压缩)个字节,
   data 小于该指定的长度则写入全部数据。

Enchant拼写检查类

属性
命名空间 fize\misc
类名 Enchant
方法:
方法名 说明
brokerDescribe() 枚举赋值提供程序
brokerDictExists() 使用非空标记告诉字典是否存在
brokerFreeDict() 释放当前字典资源
brokerFree() 释放代理资源及其字典
brokerGetDictPath() 获取给定后端目录路径。
brokerGetError() 获取代理最后的错误信息
brokerInit() 创建一个能够请求的代理对象
brokerListDicts() 返回包含详细信息的可用字典列表
brokerRequestDict() 使用标记创建一个新字典
brokerRequestPwlDict() 使用PWL文件创建字典
brokerSetDictPath() 为给定后端设置目录路径
brokerSetOrdering() 声明要为该语言使用的词典的首选项
dictAddToPersonal() 在个人单词列表中添加一个单词
dictAddToSession() 在当前会话中添加一个单词
dictCheck() 检查一个单词的拼写是否正确
dictDescribe() 描述单个字典
dictGetError() 返回当前拼写会话的最后一个错误
dictIsInSession() 在这个拼写过程中是否存在 “word”
dictQuickCheck() 检查单词拼写是否正确,并提供建议
dictStoreReplacement() 为一个单词加一个改正
dictSuggest() 如果单词拼写错误,将返回一个建议数组。
方法
brokerDescribe()

枚举赋值提供程序

public function brokerDescribe () : array
brokerDictExists()

使用非空标记告诉字典是否存在

public function brokerDictExists (

    string $tag

) : bool
参数:
名称 说明
tag 标识
brokerFreeDict()

释放当前字典资源

public function brokerFreeDict () : bool
brokerFree()

释放代理资源及其字典

public function brokerFree () : bool
brokerGetDictPath()

获取给定后端目录路径。

public function brokerGetDictPath (

    int $dict_type

) : string
参数:
名称 说明
dict_type 字典类型
参数 `$dict_type` :
可选值:ENCHANT_MYSPELL  ENCHANT_ISPELL.
brokerGetError()

获取代理最后的错误信息

public function brokerGetError () : string
brokerInit()

创建一个能够请求的代理对象

public function brokerInit () : resource
brokerListDicts()

返回包含详细信息的可用字典列表

public function brokerListDicts () : array
brokerRequestDict()

使用标记创建一个新字典

public function brokerRequestDict (

    string $tag

) : resource
参数:
名称 说明
tag 标识
brokerRequestPwlDict()

使用PWL文件创建字典

public function brokerRequestPwlDict (

    string $filename

) : resource
参数:
名称 说明
filename PWL文件
brokerSetDictPath()

为给定后端设置目录路径

public function brokerSetDictPath (

    int $dict_type,

    string $value

)
参数:
名称 说明
dict_type 字典类型
value 字典目录的路径。
参数 `$dict_type` :
可选值:ENCHANT_MYSPELL  ENCHANT_ISPELL.
brokerSetOrdering()

声明要为该语言使用的词典的首选项

public function brokerSetOrdering (

    string $tag,

    string $ordering

) : bool
参数:
名称 说明
tag 语言标签
ordering 用逗号分隔的提供程序名称列表
特殊的 * 标记可以用作语言标记来声明任何没有显式声明排序的语言的默认排序。
dictAddToPersonal()

在个人单词列表中添加一个单词

public function dictAddToPersonal (

    string $word

)
参数:
名称 说明
word 要添加的单词
dictAddToSession()

在当前会话中添加一个单词

public function dictAddToSession (

    string $word

)
参数:
名称 说明
word 要添加的单词
dictCheck()

检查一个单词的拼写是否正确

public function dictCheck (

    string $word

) : bool
参数:
名称 说明
word 要检查的单词
dictDescribe()

描述单个字典

public function dictDescribe () : array
dictGetError()

返回当前拼写会话的最后一个错误

public function dictGetError () : string
dictIsInSession()

在这个拼写过程中是否存在 “word”

public function dictIsInSession (

    string $word

) : bool
参数:
名称 说明
word 要检查的单词
dictQuickCheck()

检查单词拼写是否正确,并提供建议

public function dictQuickCheck (

    string $word,

    array &$suggestions = null

) : bool
参数:
名称 说明
word 要检查的单词
suggestions 如果单词拼写不正确,这个变量将包含一个建议数组。
dictStoreReplacement()

为一个单词加一个改正

public function dictStoreReplacement (

    string $mis,

    string $cor

)
参数:
名称 说明
mis 要修正的单词
cor 使用该词替换
dictSuggest()

如果单词拼写错误,将返回一个建议数组。

public function dictSuggest (

    string $word

) : array
参数:
名称 说明
word 要检查的单词

iconv编码类

属性
命名空间 fize\misc
类名 Iconv
常量:
名称 说明
WIN_UTF8_2_GBK 0 windows环境下的UTF8字符串转GBK
WIN_GBK_2_UTF8 1 windows环境下的GBK字符串转UTF8
方法:
方法名 说明
getEncoding() 获取 iconv 扩展的内部配置变量
mimeDecodeHeaders() 一次性解码多个 MIME 头字段
mimeDecode() 解码一个MIME头字段
mimeEncode() 编码一个MIME头
setEncoding() 为字符编码转换设定当前设置
strlen() 返回字符串的字符数统计
strpos() 查找字符串首次出现的位置
strrpos() 从右查找字符串首次出现的位置
substr() 截取字符串的部分
iconv() 将字符串 str 从 in_charset 转换编码到 out_charset。
serialize() 对要使用的字符串进行中文兼容性处理
winUtf8ToGbk() 方向 WIN_UTF8_2_GBK
winGbkToUtf8() 方向 WIN_GBK_2_UTF8
常量
WIN_UTF8_2_GBK

windows环境下的UTF8字符串转GBK

修饰符:public
类型:int
值:0
WIN_GBK_2_UTF8

windows环境下的GBK字符串转UTF8

修饰符:public
类型:int
值:1
方法
getEncoding()

获取 iconv 扩展的内部配置变量

public static function getEncoding (

    string $type = "all"

) : array|string
参数:
名称 说明
type 类型
返回值:

返回当前内部配置变量的值。

参数 `$type` :
可选值:all、input_encoding、output_encoding、internal_encoding
mimeDecodeHeaders()

一次性解码多个 MIME 头字段

public static function mimeDecodeHeaders (

    string $encoded_headers,

    int $mode = 0,

    string $charset = null

) : array
参数:
名称 说明
encoded_headers 编码过的头字符串。
mode 决定了遇到畸形 MIME 头字段时的行为
charset 指定编码
参数 `$mode` :
  可选值:ICONV_MIME_DECODE_STRICT、ICONV_MIME_DECODE_CONTINUE_ON_ERROR
参数 `$charset` :
  如果省略了,将使用 iconv.internal_encoding。
mimeDecode()

解码一个MIME头字段

public static function mimeDecode (

    string $encoded_header,

    int $mode = 0,

    string $charset = null

) : string
参数:
名称 说明
encoded_header 编码头,是一个字符串.
mode 决定了遇到畸形 MIME 头字段时的行为
charset 指定编码
返回值:

如果解码成功,返回一个被解码的MIME字段,

参数 `$mode` :
  可选值:ICONV_MIME_DECODE_STRICT、ICONV_MIME_DECODE_CONTINUE_ON_ERROR
参数 `$charset` :
  如果省略了,将使用 iconv.internal_encoding。
如果在解码过程中出现一个错误,将返回FALSE .
mimeEncode()

编码一个MIME头

public static function mimeEncode (

    string $field_name,

    string $field_value,

    array $preferences = null

) : string
参数:
名称 说明
field_name
field_value
preferences 可选参数
返回值:

返回编码后的字符串

setEncoding()

为字符编码转换设定当前设置

public static function setEncoding (

    string $type,

    string $charset

) : bool
参数:
名称 说明
type 类型
charset 字符集。
返回值:

成功时返回 TRUE, 或者在失败时返回 FALSE。

参数 `$type` :
可选值:input_encoding、output_encoding、internal_encoding
strlen()

返回字符串的字符数统计

public static function strlen (

    string $str,

    string $charset = null

) : int
参数:
名称 说明
str 该字符串
charset 编码
返回值:

返回 str 字符数的统计。

参数 `$charset` :
如果省略了 charset 参数,假设 str 的编码为 iconv.internal_encoding。
strpos()

查找字符串首次出现的位置

public static function strpos (

    string $haystack,

    string $needle,

    int $offset = 0,

    string $charset = null

) : int
参数:
名称 说明
haystack 要寻找的字符
needle 被查找的字符串
offset 偏移
charset 编码
参数 `$charset` :
如果省略了 charset 参数,假设 str 的编码为 iconv.internal_encoding。
strrpos()

从右查找字符串首次出现的位置

public static function strrpos (

    string $haystack,

    string $needle,

    string $charset = null

) : int
参数:
名称 说明
haystack 要寻找的字符
needle 被查找的字符串
charset 编码
参数 `$charset` :
如果省略了 charset 参数,假设 str 的编码为 iconv.internal_encoding。
substr()

截取字符串的部分

public static function substr (

    string $str,

    int $offset,

    int $length = null,

    string $charset = null

) : string
参数:
名称 说明
str 原始字符串。
offset 偏移
length 指定长度
charset 编码
返回值:

返回 offset 和 length 参数指定的 str 的部分。

参数 `$charset` :
  如果省略了 charset 参数,假设 str 的编码为 iconv.internal_encoding。
如果 str  offset 字符数更短,将会返回 FALSE 如果 str  offset 个字符的长度,将返回空字符串。
iconv()

将字符串 str 从 in_charset 转换编码到 out_charset。

public static function iconv (

    string $in_charset,

    string $out_charset,

    string $str

) : string
参数:
名称 说明
in_charset 输入的字符集。
out_charset 输出的字符集。
str 要转换的字符串。
serialize()

对要使用的字符串进行中文兼容性处理

public static function serialize (

    string $str,

    string $direction

) : string
参数:
名称 说明
str 待处理字符串
direction 方向 WIN_UTF8_2_GBK,WIN_GBK_2_UTF8
返回值:

处理后字符串

Windows、Linux系统针对中文字符创的兼容性处理
Windows由于使用GBK编码会导致中文路径乱码,进行UTF-8字符串转GBK字符串后再建立
winUtf8ToGbk()

方向 WIN_UTF8_2_GBK

public static function winUtf8ToGbk (

    string $str

) : string
参数:
名称 说明
str 待处理字符串
winGbkToUtf8()

方向 WIN_GBK_2_UTF8

public static function winGbkToUtf8 (

    string $str

) : string
参数:
名称 说明
str 待处理字符串

MbString类

属性
命名空间 fize\misc
类名 MbString
方法:
方法名 说明
checkEncoding() 检查指定的字节流在指定的编码里是否有效
chr() 获取特定字符
convertCase() 对字符串进行大小写转换,转换模式由 mode 指定。
convertEncoding() 转换字符的编码
convertKana() 将“假名”从另一个转换为另一个(“zen-kaku”、“han-kaku”等等)
convertVariables() 转换一个或多个变量的字符编码
decodeMimeheader() 解码 MIME 头字段中的字符串
decodeNumericentity() 根据 HTML 数字字符串解码成字符
detectEncoding() 检测字符的编码
detectOrder() 设置/获取 字符编码的检测顺序
encodeMimeheader() 为 MIME 头编码字符串
encodeNumericentity() 将字符编码为HTML数字字符串引用
encodingAliases() 获取已知编码类型的别名
eregMatch() 正则表达式匹配多字节字符串
eregReplaceCallback() 使用回调函数执行正则表达式搜索并使用多字节支持替换
eregReplace() 用多字节支持替换正则表达式
eregSearchGetpos() 返回下一个正则表达式匹配的起始点
eregSearchGetregs() 从最后一个多字节正则表达式匹配中检索结果
eregSearchInit() 为多字节正则表达式匹配设置字符串和正则表达式
eregSearchPos() 返回预定义多字节正则表达式的匹配部分的位置和长度
eregSearchRegs() 返回多字节正则表达式的匹配部分
eregSearchSetpos() 设置下一个正则表达式匹配的起始点
eregSearch() 多字节正则表达式匹配预定义的多字节字符串
ereg() 正则表达式匹配多字节支持
eregiReplace() 用多字节支持忽略大小写替换正则表达式
eregi() 正则表达式匹配多字节支持的忽略大小写
getInfo() 获取 mbstring 的内部设置
httpInput() 检测 HTTP 输入字符的编码
httpOutput() 设置/获取 HTTP 输出字符编码
internalEncoding() 设置/获取内部字符编码
language() 设置/获取当前的语言
listEncodings() 返回所有支持编码的数组
ord() 获取字符的代码点
outputHandler() 在输出缓冲中转换字符编码的回调函数
parseStr() 解析 GET/POST/COOKIE 数据并设置全局变量
preferredMimeName() 获取 MIME 字符串
regexEncoding() 设置/获取多字节正则表达式的字符编码
regexSetOptions() 设置/获取mbregex函数的默认选项
scrub() 清理格式不正确的字符
sendMail() 发送编码过的邮件
split() 使用正则表达式分割多字节字符串
strcut() 获取字符的一部分
strimwidth() 获取按指定宽度截断的字符串
stripos() 大小写不敏感地查找字符串在另一个字符串中首次出现的位置
stristr() 大小写不敏感地查找字符串在另一个字符串里的首次出现
strlen() 获取字符串的长度
strpos() 查找字符串在另一个字符串中首次出现的位置
strrchr() 查找指定字符在另一个字符串中最后一次的出现
strrichr() 大小写不敏感地查找指定字符在另一个字符串中最后一次的出现
strripos() 大小写不敏感地在字符串中查找一个字符串最后出现的位置
strrpos() 查找字符串在一个字符串中最后出现的位置
strstr() 查找字符串在另一个字符串里的首次出现,并返回指定部分字符串
strtolower() 使字符串小写
strtoupper() 使字符串大写
strwidth() 返回字符串的宽度,多字节字符通常是单字节字符的两倍宽度。
substituteCharacter() 设置/获取替代字符
substrCount() 统计字符串出现的次数
substr() 获取部分字符串
方法
checkEncoding()

检查指定的字节流在指定的编码里是否有效

public static function checkEncoding (

    string $var = null,

    string $encoding = null

) : bool
参数:
名称 说明
var 要检查的字节流
encoding 期望的编码
该方法能有效避免所谓的"无效编码攻击(Invalid Encoding Attack)"
参数 `$var` :
  如果省略了参数 `$var` ,此函数会检查所有来自最初请求所有的输入。
chr()

获取特定字符

public static function chr (

    int $cp,

    string $encoding

) : string
参数:
名称 说明
cp 字符编码
encoding 编码
convertCase()

对字符串进行大小写转换,转换模式由 mode 指定。

public static function convertCase (

    string $str,

    int $mode,

    string $encoding = null

) : string
参数:
名称 说明
str 要转化的字符串
mode 转换的模式
encoding 字符编码
参数 `$mode` :
  可以是 MB_CASE_UPPER、 MB_CASE_LOWER  MB_CASE_TITLE 的其中一个
参数 `$encoding` :
  如果省略,则使用内部字符编码。
convertEncoding()

转换字符的编码

public static function convertEncoding (

    string $str,

    string $to_encoding,

    string $from_encoding = null

) : string
参数:
名称 说明
str 要转码的字符串
to_encoding 要转换成的编码类型。
from_encoding 原编码
参数 `$from_encoding` :
如果没有提供,则会使用内部(internal)编码。
convertKana()

将“假名”从另一个转换为另一个(“zen-kaku”、“han-kaku”等等)

public static function convertKana (

    string $str,

    string $option = "KV",

    string $encoding = null

) : string
参数:
名称 说明
str 要转码的字符串
option 转码选项
encoding 原编码
参数 `$encoding` :
如果没有提供,则会使用内部(internal)编码。
convertVariables()

转换一个或多个变量的字符编码

public static function convertVariables (

    string $to_encoding,

    string $from_encoding,

    mixed &...$vars

) : string
参数:
名称 说明
to_encoding 指定编码
from_encoding 原编码
vars 要转换的变量的引用。
返回值:

转换前的字符编码

该方法假设所有的参数都具有同样的编码。
参数 `$vars` :
  可以接受 String、Array  Object 的类型。
decodeMimeheader()

解码 MIME 头字段中的字符串

public static function decodeMimeheader (

    string $str

) : string
参数:
名称 说明
str 要解码的字符串
decodeNumericentity()

根据 HTML 数字字符串解码成字符

public static function decodeNumericentity (

    string $str,

    array $convmap,

    string $encoding = null

) : string
参数:
名称 说明
str 要解码的字符串
convmap 指定了要转换的代码区域。
encoding 字符编码。
参数 `$encoding` :
如果省略参数 `$encoding` ,则使用内部字符编码。
detectEncoding()

检测字符的编码

public static function detectEncoding (

    string $str,

    array|string $encoding_list = null,

    bool $strict = false

) : string
参数:
名称 说明
str 待检查的字符串
encoding_list 字符编码列表
strict 是否严格地检测编码
编码顺序可以由数组或者逗号分隔的列表字符串指定
detectOrder()

设置/获取 字符编码的检测顺序

public static function detectOrder (

    array|string $encoding_list = null

) : bool|array
参数:
名称 说明
encoding_list 一个数组或者逗号分隔的字符编码列表
设置编码检测顺序时候,成功时返回 TRUE,识别时候返回 FALSE
在获取编码检测顺序的时候,会返回排序过的编码数组。
encodeMimeheader()

为 MIME 头编码字符串

public static function encodeMimeheader (

    string $str,

    string $charset = null,

    string $transfer_encoding = "B",

    string $linefeed = "

",

    int $indent = 0

) : string
参数:
名称 说明
str 要编码的字符串
charset 指定了 str 的字符集名
transfer_encoding 指定了 MIME 的编码方案
linefeed 指定了 EOL(行尾)标记
indent 首行缩进(header 里 str 前的字符数目)
返回值:

转换后的字符串版本以 ASCII 形式表达。

参数 `$transfer_encoding` :
可以是 "B"(Base64)也可以是 "Q"(Quoted-Printable)。如果未设置,将回退为 "B"
encodeNumericentity()

将字符编码为HTML数字字符串引用

public static function encodeNumericentity (

    string $str,

    array $convmap,

    string $encoding = null,

    bool $is_hex = false

) : string
参数:
名称 说明
str 要编码的字符串
convmap 指定要转换的代码区域。
encoding 指定编码
is_hex 是否为16进制字符串
encodingAliases()

获取已知编码类型的别名

public static function encodingAliases (

    string $encoding

) : string[]
参数:
名称 说明
encoding 编码
eregMatch()

正则表达式匹配多字节字符串

public static function eregMatch (

    string $pattern,

    string $string,

    string $option = null

) : bool
参数:
名称 说明
pattern 正则表达式
string 要匹配的字符串
option 匹配的选项
eregReplaceCallback()

使用回调函数执行正则表达式搜索并使用多字节支持替换

public static function eregReplaceCallback (

    string $pattern,

    callable $callback,

    string $string,

    string $option = "msr"

) : string
参数:
名称 说明
pattern 正则表达式
callback 回调函数
string 要匹配的字符串
option 匹配的选项
eregReplace()

用多字节支持替换正则表达式

public static function eregReplace (

    string $pattern,

    string $replacement,

    string $string,

    string $option = "msr"

) : string
参数:
名称 说明
pattern 正则表达式
replacement 要替换成的字符串
string 要匹配的字符串
option 匹配的选项
eregSearchGetpos()

返回下一个正则表达式匹配的起始点

public static function eregSearchGetpos () : int
eregSearchGetregs()

从最后一个多字节正则表达式匹配中检索结果

public static function eregSearchGetregs () : string[]
eregSearchInit()

为多字节正则表达式匹配设置字符串和正则表达式

public static function eregSearchInit (

    string $string,

    string $pattern = null,

    string $option = null

) : bool
参数:
名称 说明
string 要匹配的字符串
pattern 正则表达式
option 匹配的选项
eregSearchPos()

返回预定义多字节正则表达式的匹配部分的位置和长度

public static function eregSearchPos (

    string $pattern = null,

    string $option = null

) : int[]
参数:
名称 说明
pattern 正则表达式
option 匹配的选项
eregSearchRegs()

返回多字节正则表达式的匹配部分

public static function eregSearchRegs (

    string $pattern = null,

    string $option = null

) : string[]
参数:
名称 说明
pattern 正则表达式
option 匹配的选项
eregSearchSetpos()

设置下一个正则表达式匹配的起始点

public static function eregSearchSetpos (

    int $position

) : bool
参数:
名称 说明
position 起始点
eregSearch()

多字节正则表达式匹配预定义的多字节字符串

public static function eregSearch (

    string $pattern = null,

    string $option = null

) : bool
参数:
名称 说明
pattern 正则表达式
option 匹配的选项
ereg()

正则表达式匹配多字节支持

public static function ereg (

    string $pattern,

    string $string,

    array &$regs = null

) : int
参数:
名称 说明
pattern 正则表达式
string 要匹配的字符串
regs 匹配项将存储在该数组的元素中
eregiReplace()

用多字节支持忽略大小写替换正则表达式

public static function eregiReplace (

    string $pattern,

    string $replace,

    string $string,

    string $option = "msr"

) : string
参数:
名称 说明
pattern 正则表达式
replace 要替换成的字符串
string 要匹配的字符串
option 匹配的选项
eregi()

正则表达式匹配多字节支持的忽略大小写

public static function eregi (

    string $pattern,

    string $string,

    array &$regs = null

) : int
参数:
名称 说明
pattern 正则表达式
string 要搜索的字符串
regs 匹配项将存储在该数组的元素中
getInfo()

获取 mbstring 的内部设置

public static function getInfo (

    string $type = null

) : mixed
参数:
名称 说明
type 指定返回类型
返回值:

如果没有指定 type 将返回类型信息的数组,否则将返回指定 type 的信息。

httpInput()

检测 HTTP 输入字符的编码

public static function httpInput (

    string $type = null

) : mixed
参数:
名称 说明
type 设置的字符串指定了输入类型
返回值:

如果没有处理过任何指定的 HTTP 输入,它将返回 FALSE。

参数 `$type` :
"G"  GET,"P"  POST,"C"  COOKIE,"S"  string,"L"  list,以及 "I" 是整个列表
httpOutput()

设置/获取 HTTP 输出字符编码

public static function httpOutput (

    string $encoding = null

) : mixed
参数:
名称 说明
encoding 设置编码
返回值:

如果省略了 encoding,返回当前的 HTTP 输出字符编码。否则成功时返回 TRUE, 或者在失败时返回 FALSE。

internalEncoding()

设置/获取内部字符编码

public static function internalEncoding (

    string $encoding = null

) : mixed
参数:
名称 说明
encoding 设置编码
返回值:

如果省略了 encoding,返回当前的内部字符编码。否则成功时返回 TRUE, 或者在失败时返回 FALSE。

language()

设置/获取当前的语言

public static function language (

    string $language = null

) : mixed
参数:
名称 说明
language 用于编码邮件信息
返回值:

如果设置了 language,并且 language 是有效的,它将返回 TRUE,否则将返回 FALSE。

有效的语言有:"Japanese","ja","English","en"  "uni"(UTF-8)。
listEncodings()

返回所有支持编码的数组

public static function listEncodings () : array
ord()

获取字符的代码点

public static function ord (

    string $str,

    string $encoding

) : int
参数:
名称 说明
str 字符串
encoding 编码
outputHandler()

在输出缓冲中转换字符编码的回调函数

public static function outputHandler (

    string $contents,

    int $status

) : string
参数:
名称 说明
contents 输出缓冲的内容
status 输出缓冲的状态
parseStr()

解析 GET/POST/COOKIE 数据并设置全局变量

public static function parseStr (

    string $encoded_string,

    array &$result = null

) : bool
参数:
名称 说明
encoded_string URL 编码过的数据
result 一个数组,包含解码过的、编码转换后的值。
preferredMimeName()

获取 MIME 字符串

public static function preferredMimeName (

    string $encoding

) : string
参数:
名称 说明
encoding 要检查的字符串
regexEncoding()

设置/获取多字节正则表达式的字符编码

public static function regexEncoding (

    string $encoding = null

) : bool|string
参数:
名称 说明
encoding 编码
返回值:

设置时返回true或false,获取时返回string

regexSetOptions()

设置/获取mbregex函数的默认选项

public static function regexSetOptions (

    string $options = null

) : string
参数:
名称 说明
options 选项
scrub()

清理格式不正确的字符

public static function scrub (

    string $str,

    string $encoding

) : string
参数:
名称 说明
str 字符串
encoding 编码
sendMail()

发送编码过的邮件

public static function sendMail (

    string $to,

    string $subject,

    string $message,

    string $additional_headers = null,

    string $additional_parameter = null

) : bool
参数:
名称 说明
to 被发送到该邮件地址
subject 邮件标题
message 邮件消息
additional_headers 要插入到电子邮件标题末尾的字符串。
additional_parameter MTA 命令行参数
可通过逗号分隔地址的 `$to` 来指定多个收件人。该参数不会被自动编码
参数 `$additional_parameter` :
  在使用 sendmail 时对设置正确的返回路径头很有帮助
split()

使用正则表达式分割多字节字符串

public static function split (

    string $pattern,

    string $string,

    int $limit = null

) : array
参数:
名称 说明
pattern 正则表达式
string 待分割的字符串
limit 最多分割为 limit 个元素
strcut()

获取字符的一部分

public static function strcut (

    string $str,

    int $start,

    int $length = null,

    string $encoding = null

) : string
参数:
名称 说明
str 字符串
start 开始偏移量
length 长度
encoding 编码
参数 `$start` :
负表示返回的字符串是从 str 末尾处第 start 个字节开始的
strimwidth()

获取按指定宽度截断的字符串

public static function strimwidth (

    string $str,

    int $start,

    int $width,

    string $trimmarker = null,

    string $encoding = null

) : string
参数:
名称 说明
str 字符串
start 开始位置的偏移
width 所需修剪的宽度。负数的宽度是从字符串结尾处统计的。
trimmarker 当字符串被截短的时候,将此字符串添加到截短后的末尾。
encoding 字符编码。如果省略,则使用内部字符编码
参数 `$start` :
从这些字符数开始的截取字符串。(默认是 0 个字符)。
如果 start 是负数,就是字符串结尾处的字符数。
stripos()

大小写不敏感地查找字符串在另一个字符串中首次出现的位置

public static function stripos (

    string $haystack,

    string $needle,

    int $offset = 0,

    string $encoding = null

) : int|bool
参数:
名称 说明
haystack 被查找的字符串
needle 要查找这个字符串
offset 开始搜索的位置
encoding 使用的字符编码名称
返回值:

没找到返回false

参数 `$offset` :
  如果是负数,就从字符串的尾部开始统计。
参数 `$encoding` :
  如果省略了它,将使用内部字符编码。
stristr()

大小写不敏感地查找字符串在另一个字符串里的首次出现

public static function stristr (

    string $haystack,

    string $needle,

    bool $before_needle = false,

    string $encoding = null

) : string|bool
参数:
名称 说明
haystack 被查找的字符串
needle 要查找这个字符串
before_needle 决定这个函数返回 haystack 的哪一部分
encoding 使用的字符编码名称
返回值:

返回指定部分字符串,没找到时返回false

参数 `$encoding` :
如果省略了它,将使用内部字符编码。
strlen()

获取字符串的长度

public static function strlen (

    string $str,

    string $encoding = null

) : int|bool
参数:
名称 说明
str 字符串
encoding 编码
返回值:

如果给定的 encoding 无效则返回 FALSE

strpos()

查找字符串在另一个字符串中首次出现的位置

public static function strpos (

    string $haystack,

    string $needle,

    int $offset = 0,

    string $encoding = null

) : int|bool
参数:
名称 说明
haystack 被查找的字符串
needle 要查找这个字符串
offset 搜索位置的偏移
encoding 字符编码
返回值:

没找到时返回false

参数 `$offset` :
  如果没有提供该参数,将会使用 0。负数的 offset 会从字符串尾部开始统计。
参数 `$encoding` :
  如果省略,则使用内部字符编码。
strrchr()

查找指定字符在另一个字符串中最后一次的出现

public static function strrchr (

    string $haystack,

    string $needle,

    bool $before_needle = false,

    string $encoding = null

) : string|bool
参数:
名称 说明
haystack 被查找的字符串
needle 要查找这个字符串
before_needle 决定这个函数返回 haystack 的哪一部分
encoding 使用的字符编码名称
返回值:

返回指定部分字符串,没找到时返回false

参数 `$encoding` :
如果省略,则使用内部字符编码。
strrichr()

大小写不敏感地查找指定字符在另一个字符串中最后一次的出现

public static function strrichr (

    string $haystack,

    string $needle,

    bool $before_needle = false,

    string $encoding = null

) : string|bool
参数:
名称 说明
haystack 被查找的字符串
needle 要查找这个字符串
before_needle 决定这个函数返回 haystack 的哪一部分
encoding 使用的字符编码名称
返回值:

返回指定部分字符串,没找到时返回false

参数 `$encoding` :
如果省略,则使用内部字符编码。
strripos()

大小写不敏感地在字符串中查找一个字符串最后出现的位置

public static function strripos (

    string $haystack,

    string $needle,

    int $offset = 0,

    string $encoding = null

) : int|bool
参数:
名称 说明
haystack 被查找的字符串
needle 要查找这个字符串
offset 开始搜索的位置
encoding 使用的字符编码名称
返回值:

没找到时返回false

参数 `$encoding` :
如果省略,则使用内部字符编码。
strrpos()

查找字符串在一个字符串中最后出现的位置

public static function strrpos (

    string $haystack,

    string $needle,

    int $offset = 0,

    string $encoding = null

) : int|bool
参数:
名称 说明
haystack 被查找的字符串
needle 要查找这个字符串
offset 开始搜索的位置
encoding 使用的字符编码名称
返回值:

没找到时返回false

参数 `$encoding` :
如果省略,则使用内部字符编码。
strstr()

查找字符串在另一个字符串里的首次出现,并返回指定部分字符串

public static function strstr (

    string $haystack,

    string $needle,

    bool $before_needle = false,

    string $encoding = null

) : string|bool
参数:
名称 说明
haystack 被查找的字符串
needle 要查找这个字符串
before_needle 决定这个函数返回 haystack 的哪一部分
encoding 使用的字符编码名称
返回值:

没找到时返回false

参数 `$encoding` :
如果省略,则使用内部字符编码。
strtolower()

使字符串小写

public static function strtolower (

    string $str,

    string $encoding = null

) : string
参数:
名称 说明
str 字符串
encoding 使用的字符编码名称
参数 `$encoding` :
如果省略,则使用内部字符编码。
strtoupper()

使字符串大写

public static function strtoupper (

    string $str,

    string $encoding = null

) : string
参数:
名称 说明
str 字符串
encoding 使用的字符编码名称
参数 `$encoding` :
如果省略,则使用内部字符编码。
strwidth()

返回字符串的宽度,多字节字符通常是单字节字符的两倍宽度。

public static function strwidth (

    string $str,

    string $encoding = null

) : int
参数:
名称 说明
str 字符串
encoding 使用的字符编码名称
参数 `$encoding` :
如果省略,则使用内部字符编码。
substituteCharacter()

设置/获取替代字符

public static function substituteCharacter (

    mixed $substrchar = null

) : mixed
参数:
名称 说明
substrchar 指定替代选项
返回值:

设置时,在成功时返回 TRUE,失败时返回 FALSE。否则返回当前设置。

substrCount()

统计字符串出现的次数

public static function substrCount (

    string $haystack,

    string $needle,

    string $encoding = null

) : int
参数:
名称 说明
haystack 被查找的字符串
needle 要查找这个字符串
encoding 使用的字符编码名称
参数 `$encoding` :
如果省略,则使用内部字符编码。
substr()

获取部分字符串

public static function substr (

    string $str,

    int $start,

    int $length = null,

    string $encoding = null

) : string
参数:
名称 说明
str 字符串
start 开始下标
length 获取长度
encoding 使用的字符编码
参数 `$encoding` :
如果省略,则使用内部字符编码。

正则操作类

属性
命名空间 fize\misc
类名 Preg
方法:
方法名 说明
filter() 执行一个正则表达式搜索和替换
grep() 返回匹配模式的数组条目
lastError() 返回最后一个PCRE正则执行产生的错误代码
matchAll() 执行一个全局正则表达式匹配
match() 执行一个正则表达式匹配
quote() 转义正则表达式字符
replaceCallbackArray() 使用回调执行正则表达式搜索和替换
replaceCallback() 执行一个正则表达式搜索并且使用一个回调进行替换
replace() 执行一个正则表达式的搜索和替换
split() 通过一个正则表达式分隔字符串
方法
filter()

执行一个正则表达式搜索和替换

public static function filter (

    mixed $pattern,

    mixed $replacement,

    mixed $subject,

    int $limit = -1,

    int &$count = null

) : mixed
参数:
名称 说明
pattern 要搜索的模式。可以使一个字符串或字符串数组。
replacement 用于替换的字符串或字符串数组。
subject 要进行搜索和替换的字符串或字符串数组。
limit 每个模式在每个subject上进行替换的最大次数。默认是 -1(无限)。
count 如果指定,将会被填充为完成的替换次数。
返回值:

如果subject是一个数组,返回一个数组, 其他情况返回一个字符串。

Preg::filter() 等价于 Preg::replace() 除了它仅仅返回(可能经过转化)与目标匹配的结果
参数 `$replacement` :
  如果这个参数是一个字符串,并且pattern 是一个数组,那么所有的模式都使用这个字符串进行替换。
  如果pattern和replacement 都是数组,每个pattern使用replacement中对应的 元素进行替换。
  如果replacement中的元素比pattern中的少, 多出来的pattern使用空字符串进行替换。
参数 `$subject` :
  如果subject是一个数组,搜索和替换回在subject 的每一个元素上进行, 并且返回值也会是一个数组。
如果没有找到匹配或者发生了错误,当subject是数组 时返回一个空数组,其他情况返回NULL。
grep()

返回匹配模式的数组条目

public static function grep (

    string $pattern,

    array $input,

    int $flags = 0

) : array
参数:
名称 说明
pattern 要搜索的模式
input 输入数组
flags 标识
参数 `$flags` :
如果设置为PREG_GREP_INVERT, 这个函数返回输入数组中与给定模式pattern不匹配的元素组成的数组。
lastError()

返回最后一个PCRE正则执行产生的错误代码

public static function lastError () : int
matchAll()

执行一个全局正则表达式匹配

public static function matchAll (

    string $pattern,

    string $subject,

    array &$matches = null,

    int $flags = 1,

    int $offset = 0

) : int
参数:
名称 说明
pattern 要搜索的模式,字符串形式。
subject 输入字符串。
matches 多维数组,作为输出参数输出所有匹配结果
flags 数组排序通过flags指定。
offset 用于从目标字符串中指定位置开始搜索(单位是字节)。
返回值:

返回完整匹配次数(可能是0),或者如果发生错误返回FALSE。

match()

执行一个正则表达式匹配

public static function match (

    string $pattern,

    string $subject,

    array &$matches = null,

    int $flags = 0,

    int $offset = 0

) : int
参数:
名称 说明
pattern 要搜索的模式,字符串形式。
subject 输入字符串。
matches 搜索结果
flags flags可以被设置为以下标记值: PREG_OFFSET_CAPTURE
offset 偏移位置
返回值:

返回 pattern 的匹配次数

参数 `$matches` :
  如果提供了参数matches,它将被填充为搜索结果。
  $matches[0]将包含完整模式匹配到的文本, $matches[1] 将包含第一个捕获子组匹配到的文本,以此类推。
参数 `$$offset` :
  可选参数 offset 用于 指定从目标字符串的某个未知开始搜索(单位是字节)
返回值将是0次(不匹配)或1次,因为Preg::match()在第一次匹配后 将会停止搜索。
quote()

转义正则表达式字符

public static function quote (

    string $str,

    string $delimiter = null

) : string
参数:
名称 说明
str 输入字符串
delimiter 分隔符
返回值:

返回转义后的字符串。

参数 `$delimiter` :
如果指定了可选参数 delimiter,它也会被转义。
这通常用于 转义PCRE函数使用的分隔符。 /是最通用的分隔符。
replaceCallbackArray()

使用回调执行正则表达式搜索和替换

public static function replaceCallbackArray (

    array $patterns_and_callbacks,

    mixed $subject,

    int $limit = -1,

    int &$count = null

) : mixed
参数:
名称 说明
patterns_and_callbacks 关联数组将模式(键)映射到回调(值)。
subject 要搜索和替换字符串的字符串或数组。
limit 最大可能替换次数
count 返回被替换的次数
参数 `$limit` :
每个主题字符串中每个模式的最大可能替换。默认为-1(没有限制)
replaceCallback()

执行一个正则表达式搜索并且使用一个回调进行替换

public static function replaceCallback (

    mixed $pattern,

    callable $callback,

    mixed $subject,

    int $limit = -1,

    int &$count = null

) : mixed
参数:
名称 说明
pattern 要搜索的模式,可以使字符串或一个字符串数组。
callback 一个回调函数,在每次需要替换时调用
subject 要搜索替换的目标字符串或字符串数组。
limit 最大可替换次数
count 如果指定,这个变量将被填充为替换执行的次数。
返回值:

如果subject是一个数组, preg_replace_callback()返回一个数组,其他情况返回字符串。 错误发生时返回 NULL。

参数 `$limit` :
对于每个模式用于每个 subject 字符串的最大可替换次数。 默认是-1(无限制)。
replace()

执行一个正则表达式的搜索和替换

public static function replace (

    mixed $pattern,

    mixed $replacement,

    mixed $subject,

    int $limit = -1,

    int &$count = null

) : mixed
参数:
名称 说明
pattern 要搜索的模式。可以使一个字符串或字符串数组。
replacement 用于替换的字符串或字符串数组。
subject 要进行搜索和替换的字符串或字符串数组。
limit 替换的最大次数
count 如果指定,将会被填充为完成的替换次数。
返回值:

如果subject是一个数组, preg_replace()返回一个数组, 其他情况下返回一个字符串。

参数 `$replacement` :
  如果这个参数是一个字符串,并且pattern 是一个数组,那么所有的模式都使用这个字符串进行替换。
  如果pattern和replacement 都是数组,每个pattern使用replacement中对应的 元素进行替换。
  如果replacement中的元素比pattern中的少, 多出来的pattern使用空字符串进行替换。
参数 `$limit` :
  每个模式在每个subject上进行替换的最大次数。默认是 -1(无限)
如果匹配被查找到,替换后的subject被返回,其他情况下 返回没有改变的 subject。如果发生错误,返回 NULL 
split()

通过一个正则表达式分隔字符串

public static function split (

    string $pattern,

    string $subject,

    int $limit = -1,

    int $flags = 0

) : array
参数:
名称 说明
pattern 用于搜索的模式
subject 输入字符串
limit 最大次数
flags flags 标识
返回值:

返回一个使用 pattern 边界分隔 subject 后得到 的子串组成的数组。

参数 `$limit` 
  如果指定,将限制分隔得到的子串最多只有limit个,返回的最后一个 子串将包含所有剩余部分。
  limit值为-1 0或null时都代表"不限制"
  作为php的标准,你可以使用null跳过对flags的设置。
参数 `$flags` 
  可以是任何下面标记的组合(以位或运算 | 组合)
  PREG_SPLIT_NO_EMPTY、PREG_SPLIT_DELIM_CAPTURE、PREG_SPLIT_OFFSET_CAPTURE

系统处理类

属性
命名空间 fize\misc
类名 System
方法:
方法名 说明
debugBacktrace() 产生一条回溯跟踪(backtrace)
debugPrintBacktrace() 打印一条回溯。
debugZvalDump() 将一个字符串表示一个内部Zend值输出
errorClearLast() 清除最近的错误
errorGetLast() 获取最后发生的错误
errorLog() 发送错误信息到某个地方
errorReporting() 设置应该报告何种 PHP 错误
restoreErrorHandler() 还原之前的错误处理函数
restoreExceptionHandler() 恢复之前定义过的异常处理函数
setErrorHandler() 设置一个用户定义的错误处理函数
set_exception_handler() 设置一个用户定义的异常处理函数。
triggerError() 产生一个用户级别的 error/warning/notice 信息
userError() 产生一个用户级别的 error/warning/notice 信息
方法
debugBacktrace()

产生一条回溯跟踪(backtrace)

public static function debugBacktrace (

    int $options = 0,

    int $limit = 0

) : array
参数:
名称 说明
options 选项
limit 限制返回堆栈帧的数量
参数 `$options` :
  DEBUG_BACKTRACE_PROVIDE_OBJECT:是否填充 "object" 的索引;
  DEBUG_BACKTRACE_IGNORE_ARGS:是否忽略 "args" 的索引;
参数 `$limit` :
  这个参数能够用于限制返回堆栈帧的数量。 默认为 (limit=0) ,返回所有的堆栈帧。
debugPrintBacktrace()

打印一条回溯。

public static function debugPrintBacktrace (

    int $options = 0,

    int $limit = 0

)
参数:
名称 说明
options 选项
limit 限制返回堆栈帧的数量
参数 `$options` :
  DEBUG_BACKTRACE_IGNORE_ARGS 是否忽略 "args" 的索引
参数 `$limit` :
  这个参数能够用于限制返回堆栈帧的数量。 默认为 (limit=0) ,返回所有的堆栈帧。
debugZvalDump()

将一个字符串表示一个内部Zend值输出

public static function debugZvalDump (

    mixed $variable

)
参数:
名称 说明
variable
errorClearLast()

清除最近的错误

public static function errorClearLast ()
errorGetLast()

获取最后发生的错误

public static function errorGetLast () : array
errorLog()

发送错误信息到某个地方

public static function errorLog (

    string $message,

    int $message_type = null,

    string $destination = null,

    string $extra_headers = null

) : bool
参数:
名称 说明
message 应该被记录的错误信息。
message_type 设置错误应该发送到何处0-4
destination 目标
extra_headers 额外的头。当 message_type 设置为 1 的时候使用
参数 `$destination` :
它的含义描述于以上,由 message_type 参数所决定。
errorReporting()

设置应该报告何种 PHP 错误

public static function errorReporting (

    int $level = null

) : int
参数:
名称 说明
level 新的 error_reporting 级别
返回值:

返回旧的 error_reporting 级别,或者在 level 参数未给出时返回当前的级别。

restoreErrorHandler()

还原之前的错误处理函数

public static function restoreErrorHandler () : bool
restoreExceptionHandler()

恢复之前定义过的异常处理函数

public static function restoreExceptionHandler () : bool
setErrorHandler()

设置一个用户定义的错误处理函数

public static function setErrorHandler (

    callable $error_handler,

    int $error_types = 30719

) : mixed
参数:
名称 说明
error_handler 用户的函数
error_types 指定错误类型
set_exception_handler()

设置一个用户定义的异常处理函数。

public static function set_exception_handler (

    callable $exception_handler

) : mixed
参数:
名称 说明
exception_handler 用户的函数
triggerError()

产生一个用户级别的 error/warning/notice 信息

public static function triggerError (

    string $error_msg,

    int $error_type = 1024

) : bool
参数:
名称 说明
error_msg 该 error 的特定错误信息
error_type 该 error 所特定的错误类型
userError()

产生一个用户级别的 error/warning/notice 信息

public static function userError (

    string $error_msg,

    int $error_type = 1024

) : bool
参数:
名称 说明
error_msg 该 error 的特定错误信息
error_type 该 error 所特定的错误类型
 triggerError() 方法的别名