[PHP]PHP函数

来源:互联网 发布:证大财富淘宝贷假不假 编辑:程序博客网 时间:2024/04/30 15:42



字符串 STRING

>> 统计
strlen(string) - 长度
strcmp(string1,string2) - 比较字符串
 
>> 查找
strpos(string,find,start) - 在另一个字符串中查找, 返回第一次位置
    stripos(string,find,start) - (大小写不敏感)
    strrpos(string,find,start) - (最后一次)
    strripos(string,find,start) - (大小写不敏感)(最后一次)
strstr(string,search) - 在另一个字符串中匹配, 返回第一次匹配值及剩余部分
    stristr(string,search) - (大小写不敏感)
str_replace(find,replace,string,count) - 替换
    str_ireplace(find,replace,string,count) - (大小写不敏感)
substr(string,start,length) - 截取
 
>> 转换
explode(separator,string,limit) - 字符串 -> 数组
    implode(separator, array) - 数组 -> 字符串
    join(separator,array) - 同上
str_split(string,length) - 字符串分割为数组
parse_str(string,array) - 解析Query串为数组
strtolower(string) - 小写
    strtoupper(string) - 大写
str_shuffle(string) - 随机打散
strrev(string) - 反转
 
>> 输出
echo(string)
    print(string)
    printf(format,arg1,arg2,arg++) - 格式化输出
    fprintf(stream,format,arg1,arg2,arg++) - 格式化输出到文件
    sprintf(format,arg1,arg2,arg++) - 格式化到字符串
 
>> 格式化
str_pad(string,length,pad_string,pad_type) - 填充到指定长度
str_repeat(string,repeat) - 重复指定次数
chunk_split(string,length,end) - 插入分隔符
number_format(number,decimals,decimalpoint,separator) - 格式化数字
trim(string,charlist) - 两端清理
strip_tags(string,allow) - 剥离HTML, XML, PHP标签
 
>> 转义
addslashes(string) - 在预定义字符前添加反斜杠
    stripslashes(string)
    addcslashes(string,characters) - 在自定义字符前添加反斜杠
    stripcslashes(string)
htmlentities(string,quotestyle,character-set) - 全部字符 -> HTML实体
    html_entity_decode(string,quotestyle,character-set) - HTML实体 -> 字符
    htmlspecialchars(string,quotestyle,character-set) - 部分字符( & | " | ' | < | > ) -> HTML实体
    htmlspecialchars_decode(string,quotestyle) - HTML实体 -> 字符
nl2br(string) - /n -> <br/>
 
>> 加密
crypt(str,salt) - 单向有损加密
    md5(string,raw) - 散列
        md5_file(path,raw) - 文件有损摘要
    sha1(string,raw) - SHA1散列
        sha1_file(file,raw)
 
>> ASCII
ord(string) - 返回第一个字符的ASCII
 
 
数组 ARRAY

>> 新建&赋值
list(var1,var2,val3...) = $array - 用数组元素给变量赋值
range(min,max,step) - 建立指定范围的数组
array_combine(array1,array2) - 新建数组:array1为key,array2为value
 
>> 栈
array_pop(array) - 尾部出栈
array_push(array,value1,value2...) - 尾部入栈,相当于$array[] = $value
array_shift(array) - 首部出栈
array_unshift(array,value1,value2,value3...) - 首部入栈
 
>> 统计
array_sum(array) - 所有元素的和
array_product(array) - 所有元素的乘积
count(array,mode) - 统计元素个数,同 sizeof(array,mode)
array_count_values(array)  - 统计元素出现次数
array_keys(array,value,strict) - 返回对应的key
array_values(array) - 返回所有value
array_search(value,array,strict) - 搜索value,返回key
in_array(value,array,type) - 检查value是否存在
array_key_exists(key,array) - 检查key是否存在
 
>> 比较
array_diff(array1,array2,array3...) - 差集
    array_diff_assoc(array1,array2,array3...)
    array_diff_key(array1,array2,array3...)
array_intersect(array1,array2,array3...) - 交集
    array_intersect_assoc(array1,array2,array3...)
    array_intersect_key(array1,array2,array3...)
 
>>排序
sort(array,sorttype) - 按value升序排序(重建索引)
    rsort(array,sorttype) - 按value降序排序(重建索引)
    asort(array,sorttype) - 按value正向排序(保持索引)
    arsort(array,sorttype) - 按value逆向排序(保持索引)
    natsort(array) - 自然排序
    natcasesort(array) - 不区分大小自然排序
ksort(array,sorttype) - 按key正向排序
    krsort(array,sorttype) - 按key逆向排序
array_multisort(array,sorting order,sorting type) - 排序
shuffle(array) - 随机打乱数组排序
array_reverse(array,preserve) - 顺序反转
 
>> 修改
array_change_key_case(array,case) - 转换大小写
array_filter(array,function) - 用给定方法过滤
array_map(function,array1,array2,array3...) - 将方法用于每个元素
array_fill(start,number,value) - 用给定值填充数组
array_pad(array,size,value) - 把数组补到定长
array_flip(array) - 交换key和value
array_unique(array) - 去重
 
>> 合并&分割
array_chunk(array,size,preserve_key) - 切割
array_rand(array,number) - 随机返回数组元素(number=1时返回key)
array_slice(array,offset,length,preserve) - 截取
array_splice(array,offset,length,array) - 替换
array_merge(array1,array2,array3...) - 合并
    array_merge_recursive(array1,array2,array3...) - 递归合并(key相同时)
 
>> 指针
each(array) - 返回当前元素,并移动指针
key(array) - 当前key

current(array) - 当前value,同 pos(array)

next(array) - 下一个value
prev(array) - 上一个value
reset(array) - 移到首部

end(array) - 移到末尾

 
 
日期时间 DATE & TIME

checkdate(month,day,year) - 检查日期合法性
date(format,timestamp) - 格式化输出时间
 
>> 信息
getdate(timestamp) - 获取日期&时间信息数组
microtime(get_as_float) - 获取当前时间信息数组
 
>> 时间戳
time() - 当前时间时间戳
strtotime(time,now) - 字符串转换为时间戳
mktime(hour,minute,second,month,day,year,is_dst) - 获取时间戳
 
 
目录 DIR

opendir(path,context) - 打开目录,返回句柄
    readdir(handle) - 返回文件名
    closedir(handle) - 关闭句柄
    rewinddir(handle) - 重置句柄
dir(directory) - 打开目录,返回对象,该对象有read(),rewind(),close() 3个方法
 
 
文件 FILE

clearstatcache() - 清除文件缓存状态
parse_ini_file(file,process_sections) - 解析ini文件,返回数组
set_file_buffer(file,buffer) - 设置文件输出缓冲
 
>> 文件操作
readfile(filename,include_path,context) - 读取文件,并输出到缓冲区
    readlink(linkpath)
file(path,include_path,context) - 以数组方式读取文件
file_get_contents(path,include_path,context,start,max_length) - 读取文件到字符串
    file_put_contents(path,data,mode,context) - 写入文件
fopen(filename,mode,include_path,context) - 打开文件
    fgetc(file) - 读取字符
    fgets(file,length) - 读取一行,或指定长度
        fgetcsv(file,length,separator,enclosure) - 按CSV格式读取一行
    fputs(file,string,length) - 写文件
        fputcsv(file,fields,seperator,enclosure) - 按CSV格式写入文件
    fread(file,length) - 读取文件
    fwrite(file,string,length) - 写入文件
    fflush(file) - 输出缓冲内容到文件
    ftruncate(file,size) - 截取文件
    flock(file,lock,block) - 锁定文件
    ftell(file) - 指针位置
    fseek(file,offset,whence) - 定位指针
    rewind(file) - 重置指针位置
    feof(file) - 是否到达文件结尾
    fstat(file) - 文件信息
    fclose(file) - 关闭
tmpfile() - 创建临时文件,在fclose后删除
popen(command,mode) - 打开指向进程的管道
    pclose(pipe)
 
>> 文件状态
fstat(file) - 文件信息
    lstat(file) - 文件/软连接信息
fileatime(filename) - 上次访问时间
filectime(filename) - 上次inode信息修改时间
filemtime(filename) - 上次文件内容修改时间
filegroup(filename) - 文件用户组
fileowner(filename) - 文件用户
fileperms(filename) - 文件权限
fileinode(filename) - 文件inode
filesize(filename) - 文件大小
filetype(filename) - 文件类型
 
>> 路径
pathinfo(path,options) - 路径信息
    linkinfo(path) - 硬连接信息
basename(path,suffix) - 取文件名
dirname(path) - 取目录路径
realpath(path) - 取绝对路径
 
>> 大小
disk_total_space(directory) - 总空间大小
disk_free_space(directory) - 可用空间大小
 
>> 判断
file_exists(path) - 文件或目录是否存在
is_dir(path) - 目录
is_file(path) - 文件
is_link(path) - 连接
is_readable(path) - 可读
is_writable(path) - 可写
is_executable(path) - 可执行
 
>> 系统
mkdir(path,mode,recursive,context)
rmdir(dir,context)
link(target,link)
unlink(filename,context)
copy(source,destination)
rename(oldname,newname,context)

touch(filename,time,atime)

chgrp(filename,group)
chmod(filename,mode)
chown(filename,owner)

glob(pattern,flags)

 
>> HTTP POST
is_uploaded_file(filename) - 文件是否通过HTTP POST上传
move_uploaded_file(filename,newloc) - 移动上传的文件
 
 
错误和异常 ERROR & EXCEPTION

debug_backtrace() - 生成backtrace关联数组
    debug_print_backtrace() - 输出
error_get_last() - 获取最底层的错误
error_log(error,type,destination,headers) - 错误日志
error_reporting(report_level) - 设置错误报告级别
 
>> 触发错误/抛出异常
trigger_error(error_message,error_types) - 触发错误
throw new Exception() - 抛出异常
 
>> 指定处理函数
set_error_handler(error_function,error_types) - 错误处理函数
set_exception_handler(exception_function) - 异常处理函数
 
 
过滤器 FILTER

filter_has_var(type, variable) - 是否有该变量
filter_input(input_type, variable, filter, options) - 过滤外部输入
    filter_input_array(input_type, args)
filter_var(variable, filter, options) - 过滤变量
    filter_var_array(array, args)
 
>> Filter
SANITIZE(过滤)
    FILTER_SANITIZE_STRING - 去除或编码特殊字符
    FILTER_SANITIZE_ENCODED - 类似于urlendode
    FILTER_SANITIZE_SPECIAL_CHARS - 类似于urlendode
    FILTER_SANITIZE_MAGIC_QUOTES - 似于addslashes
    FILTER_SANITIZE_URL
    FILTER_SANITIZE_EMAIL
    FILTER_SANITIZE_NUMBER_INT
    FILTER_SANITIZE_NUMBER_FLOAT
VALIDATE(验证)
    FILTER_VALIDATE_BOOLEAN
    FILTER_VALIDATE_INT
    FILTER_VALIDATE_FLOAT
    FILTER_VALIDATE_URL
    FILTER_VALIDATE_EMAIL
    FILTER_VALIDATE_IP
    FILTER_VALIDATE_REGEXP
FILTER_CALLBACK - 调用自定义函数
 
 
文件传输 FTP

>> 连接
ftp_connect(host,port,timeout) - 建立连接
    ftp_ssl_connect(host,port,timeout) - SSL安全连接
    
    ftp_login(ftp_connection,username,password) - 登陆FTP
    ftp_raw(ftp_connection,command) - 发送命令
        ftp_exec(ftp_connection,command) - 执行命令(登陆后)
    ftp_pasv(ftp_connection,mode) - 是否被动模式
    ftp_systype(ftp_connection) - 远程机器系统
    ftp_get_option(ftp_connection,option) - 获取参数
        ftp_set_option(ftp_connection,option,value) - 设置选项
    ftp_close(ftp_connection) - 关闭连接,同 ftp_quit()
 
>> 目录
ftp_mkdir(ftp_connection,dir) - 建立目录
ftp_rmdir(ftp_connection,dir) - 删除目录
ftp_chdir(ftp_connection,dir) - 改变目录
ftp_cdup(ftp_connection) - 父目录
ftp_pwd(ftp_connection) - 当前路径
ftp_nlist(ftp_connection,dir) - 列目录
    ftp_rawlist(ftp_connection,dir,recursive) - 目录列表详情
 
>> 文件
ftp_put(ftp_connection,remote,local,mode,resume) - 上传文件
    ftp_fput(ftp_connection,remote,local,mode,resume) - 上传本地打开文件
    ftp_nb_put(ftp_connection,remote,local,mode,resume) - 异步上传
    ftp_nb_fput(ftp_connection,remote,local,mode,resume) - 异步上传本地打开文件
ftp_get(ftp_connection,local,remote,mode,resume) - 下载文件
    ftp_fget(ftp_connection,local,remote,mode,resume) - 下载到本地打开文件
    ftp_nb_get(ftp_connection,local,remote,mode,resume) - 异步下载
    ftp_nb_fget(ftp_connection,local,remote,mode,resume) - 异步下载到本地打开文件
ftp_delete(ftp_connection,path) - 删除文件
ftp_rename(ftp_connection,from,to) - 重命名
ftp_chmod(ftp_connection,mode,file) - 改变文件权限
ftp_size(ftp_connection,remote_file) - 文件大小
ftp_mdtm(ftp_connection,file) - 文件最后修改时间
 
 
HTTP

header(string,replace,http_response_code) - 发送HTTP报头
    headers_list() - 报头列表数组
    headers_sent() - 是否已发送报头
setcookie(name,value,expire,path,domain,secure) - 设置Cookie
数学 MATH

>> 算数
round() - 四舍五入
    ceil() - 向上取整
    floor() - 向下取整
max() - 返回最大值
    min() - 返回最小值
pow(x,y) - x的y次方
    sqrt() - 平方根
abs() - 绝对值
rand(min,max) - 返回随机整数
 
>> 进制
base_convert(number,frombase,tobase) - 任意进制转换
decbin() - 十进制 -> 二进制
    bindec(binary_string) - 二进制 -> 十进制
dechex() - 十进制 -> 十六进制
    hexdec() - 十六进制 -> 十进制
decoct() - 十进制 -> 八进制
    octdec() - 八进制 -> 十进制
 
>> 三角函数
cos() - 余弦
    acos() - 反余弦
sin() - 正弦
    asin() - 反正弦
tan() - 正切
    atan() -  - 反正切
 
 
MySQL

>> 连接
mysql_connect(server,user,pwd,newlink,clientflag) - 连接
    mysql_pconnect(server,user,pwd,clientflag) - 长连接
    mysql_close(connection) - 关闭
 
>> 查询
mysql_select_db(database,connection) - 选择数据库
mysql_query(sql) - 执行查询,返回资源句柄
mysql_fetch_array(data,array_type) - 查询, 返回数组
    mysql_fetch_assoc(data) - 返回关联数组
mysql_fetch_object(data) - 查询, 返回对象
mysql_num_rows(data) -  结果行数
 
>> 连接状态
mysql_ping(connection) - 检查连接, 断开则重连
mysql_thread_id(connection) - 当前连接ID
mysql_client_encoding(connection) - 当前字符集
mysql_list_dbs(connection) - 列出数据库
 
>> 上次操作
mysql_info(connection) - 上次查询的信息
mysql_affected_rows(connection) - 影响行数
mysql_insert_id(connection) - 上次插入的ID
mysql_errno(connection) - 上次错误ID
    mysql_error(connection) - 上次错误信息
 
 
输入输出 I/O

>> 打印
print_r(value)
    var_dump(value) - 带类型
    var_export(value) - 返回合法的PHP代码



出处

[PHP]PHP函数

字符串 STRING

>> 统计
strlen(string) - 长度
strcmp(string1,string2) - 比较字符串
 
>> 查找
strpos(string,find,start) - 在另一个字符串中查找, 返回第一次位置
    stripos(string,find,start) - (大小写不敏感)
    strrpos(string,find,start) - (最后一次)
    strripos(string,find,start) - (大小写不敏感)(最后一次)
strstr(string,search) - 在另一个字符串中匹配, 返回第一次匹配值及剩余部分
    stristr(string,search) - (大小写不敏感)
str_replace(find,replace,string,count) - 替换
    str_ireplace(find,replace,string,count) - (大小写不敏感)
substr(string,start,length) - 截取
 
>> 转换
explode(separator,string,limit) - 字符串 -> 数组
    implode(separator, array) - 数组 -> 字符串
    join(separator,array) - 同上
str_split(string,length) - 字符串分割为数组
parse_str(string,array) - 解析Query串为数组
strtolower(string) - 小写
    strtoupper(string) - 大写
str_shuffle(string) - 随机打散
strrev(string) - 反转
 
>> 输出
echo(string)
    print(string)
    printf(format,arg1,arg2,arg++) - 格式化输出
    fprintf(stream,format,arg1,arg2,arg++) - 格式化输出到文件
    sprintf(format,arg1,arg2,arg++) - 格式化到字符串
 
>> 格式化
str_pad(string,length,pad_string,pad_type) - 填充到指定长度
str_repeat(string,repeat) - 重复指定次数
chunk_split(string,length,end) - 插入分隔符
number_format(number,decimals,decimalpoint,separator) - 格式化数字
trim(string,charlist) - 两端清理
strip_tags(string,allow) - 剥离HTML, XML, PHP标签
 
>> 转义
addslashes(string) - 在预定义字符前添加反斜杠
    stripslashes(string)
    addcslashes(string,characters) - 在自定义字符前添加反斜杠
    stripcslashes(string)
htmlentities(string,quotestyle,character-set) - 全部字符 -> HTML实体
    html_entity_decode(string,quotestyle,character-set) - HTML实体 -> 字符
    htmlspecialchars(string,quotestyle,character-set) - 部分字符( & | " | ' | < | > ) -> HTML实体
    htmlspecialchars_decode(string,quotestyle) - HTML实体 -> 字符
nl2br(string) - /n -> <br/>
 
>> 加密
crypt(str,salt) - 单向有损加密
    md5(string,raw) - 散列
        md5_file(path,raw) - 文件有损摘要
    sha1(string,raw) - SHA1散列
        sha1_file(file,raw)
 
>> ASCII
ord(string) - 返回第一个字符的ASCII
 
 
数组 ARRAY

>> 新建&赋值
list(var1,var2,val3...) = $array - 用数组元素给变量赋值
range(min,max,step) - 建立指定范围的数组
array_combine(array1,array2) - 新建数组:array1为key,array2为value
 
>> 栈
array_pop(array) - 尾部出栈
array_push(array,value1,value2...) - 尾部入栈,相当于$array[] = $value
array_shift(array) - 首部出栈
array_unshift(array,value1,value2,value3...) - 首部入栈
 
>> 统计
array_sum(array) - 所有元素的和
array_product(array) - 所有元素的乘积
count(array,mode) - 统计元素个数,同 sizeof(array,mode)
array_count_values(array)  - 统计元素出现次数
array_keys(array,value,strict) - 返回对应的key
array_values(array) - 返回所有value
array_search(value,array,strict) - 搜索value,返回key
in_array(value,array,type) - 检查value是否存在
array_key_exists(key,array) - 检查key是否存在
 
>> 比较
array_diff(array1,array2,array3...) - 差集
    array_diff_assoc(array1,array2,array3...)
    array_diff_key(array1,array2,array3...)
array_intersect(array1,array2,array3...) - 交集
    array_intersect_assoc(array1,array2,array3...)
    array_intersect_key(array1,array2,array3...)
 
>>排序
sort(array,sorttype) - 按value升序排序(重建索引)
    rsort(array,sorttype) - 按value降序排序(重建索引)
    asort(array,sorttype) - 按value正向排序(保持索引)
    arsort(array,sorttype) - 按value逆向排序(保持索引)
    natsort(array) - 自然排序
    natcasesort(array) - 不区分大小自然排序
ksort(array,sorttype) - 按key正向排序
    krsort(array,sorttype) - 按key逆向排序
array_multisort(array,sorting order,sorting type) - 排序
shuffle(array) - 随机打乱数组排序
array_reverse(array,preserve) - 顺序反转
 
>> 修改
array_change_key_case(array,case) - 转换大小写
array_filter(array,function) - 用给定方法过滤
array_map(function,array1,array2,array3...) - 将方法用于每个元素
array_fill(start,number,value) - 用给定值填充数组
array_pad(array,size,value) - 把数组补到定长
array_flip(array) - 交换key和value
array_unique(array) - 去重
 
>> 合并&分割
array_chunk(array,size,preserve_key) - 切割
array_rand(array,number) - 随机返回数组元素(number=1时返回key)
array_slice(array,offset,length,preserve) - 截取
array_splice(array,offset,length,array) - 替换
array_merge(array1,array2,array3...) - 合并
    array_merge_recursive(array1,array2,array3...) - 递归合并(key相同时)
 
>> 指针
each(array) - 返回当前元素,并移动指针
key(array) - 当前key

current(array) - 当前value,同 pos(array)

next(array) - 下一个value
prev(array) - 上一个value
reset(array) - 移到首部

end(array) - 移到末尾

 
 
日期时间 DATE & TIME

checkdate(month,day,year) - 检查日期合法性
date(format,timestamp) - 格式化输出时间
 
>> 信息
getdate(timestamp) - 获取日期&时间信息数组
microtime(get_as_float) - 获取当前时间信息数组
 
>> 时间戳
time() - 当前时间时间戳
strtotime(time,now) - 字符串转换为时间戳
mktime(hour,minute,second,month,day,year,is_dst) - 获取时间戳
 
 
目录 DIR

opendir(path,context) - 打开目录,返回句柄
    readdir(handle) - 返回文件名
    closedir(handle) - 关闭句柄
    rewinddir(handle) - 重置句柄
dir(directory) - 打开目录,返回对象,该对象有read(),rewind(),close() 3个方法
 
 
文件 FILE

clearstatcache() - 清除文件缓存状态
parse_ini_file(file,process_sections) - 解析ini文件,返回数组
set_file_buffer(file,buffer) - 设置文件输出缓冲
 
>> 文件操作
readfile(filename,include_path,context) - 读取文件,并输出到缓冲区
    readlink(linkpath)
file(path,include_path,context) - 以数组方式读取文件
file_get_contents(path,include_path,context,start,max_length) - 读取文件到字符串
    file_put_contents(path,data,mode,context) - 写入文件
fopen(filename,mode,include_path,context) - 打开文件
    fgetc(file) - 读取字符
    fgets(file,length) - 读取一行,或指定长度
        fgetcsv(file,length,separator,enclosure) - 按CSV格式读取一行
    fputs(file,string,length) - 写文件
        fputcsv(file,fields,seperator,enclosure) - 按CSV格式写入文件
    fread(file,length) - 读取文件
    fwrite(file,string,length) - 写入文件
    fflush(file) - 输出缓冲内容到文件
    ftruncate(file,size) - 截取文件
    flock(file,lock,block) - 锁定文件
    ftell(file) - 指针位置
    fseek(file,offset,whence) - 定位指针
    rewind(file) - 重置指针位置
    feof(file) - 是否到达文件结尾
    fstat(file) - 文件信息
    fclose(file) - 关闭
tmpfile() - 创建临时文件,在fclose后删除
popen(command,mode) - 打开指向进程的管道
    pclose(pipe)
 
>> 文件状态
fstat(file) - 文件信息
    lstat(file) - 文件/软连接信息
fileatime(filename) - 上次访问时间
filectime(filename) - 上次inode信息修改时间
filemtime(filename) - 上次文件内容修改时间
filegroup(filename) - 文件用户组
fileowner(filename) - 文件用户
fileperms(filename) - 文件权限
fileinode(filename) - 文件inode
filesize(filename) - 文件大小
filetype(filename) - 文件类型
 
>> 路径
pathinfo(path,options) - 路径信息
    linkinfo(path) - 硬连接信息
basename(path,suffix) - 取文件名
dirname(path) - 取目录路径
realpath(path) - 取绝对路径
 
>> 大小
disk_total_space(directory) - 总空间大小
disk_free_space(directory) - 可用空间大小
 
>> 判断
file_exists(path) - 文件或目录是否存在
is_dir(path) - 目录
is_file(path) - 文件
is_link(path) - 连接
is_readable(path) - 可读
is_writable(path) - 可写
is_executable(path) - 可执行
 
>> 系统
mkdir(path,mode,recursive,context)
rmdir(dir,context)
link(target,link)
unlink(filename,context)
copy(source,destination)
rename(oldname,newname,context)

touch(filename,time,atime)

chgrp(filename,group)
chmod(filename,mode)
chown(filename,owner)

glob(pattern,flags)

 
>> HTTP POST
is_uploaded_file(filename) - 文件是否通过HTTP POST上传
move_uploaded_file(filename,newloc) - 移动上传的文件
 
 
错误和异常 ERROR & EXCEPTION

debug_backtrace() - 生成backtrace关联数组
    debug_print_backtrace() - 输出
error_get_last() - 获取最底层的错误
error_log(error,type,destination,headers) - 错误日志
error_reporting(report_level) - 设置错误报告级别
 
>> 触发错误/抛出异常
trigger_error(error_message,error_types) - 触发错误
throw new Exception() - 抛出异常
 
>> 指定处理函数
set_error_handler(error_function,error_types) - 错误处理函数
set_exception_handler(exception_function) - 异常处理函数
 
 
过滤器 FILTER

filter_has_var(type, variable) - 是否有该变量
filter_input(input_type, variable, filter, options) - 过滤外部输入
    filter_input_array(input_type, args)
filter_var(variable, filter, options) - 过滤变量
    filter_var_array(array, args)
 
>> Filter
SANITIZE(过滤)
    FILTER_SANITIZE_STRING - 去除或编码特殊字符
    FILTER_SANITIZE_ENCODED - 类似于urlendode
    FILTER_SANITIZE_SPECIAL_CHARS - 类似于urlendode
    FILTER_SANITIZE_MAGIC_QUOTES - 似于addslashes
    FILTER_SANITIZE_URL
    FILTER_SANITIZE_EMAIL
    FILTER_SANITIZE_NUMBER_INT
    FILTER_SANITIZE_NUMBER_FLOAT
VALIDATE(验证)
    FILTER_VALIDATE_BOOLEAN
    FILTER_VALIDATE_INT
    FILTER_VALIDATE_FLOAT
    FILTER_VALIDATE_URL
    FILTER_VALIDATE_EMAIL
    FILTER_VALIDATE_IP
    FILTER_VALIDATE_REGEXP
FILTER_CALLBACK - 调用自定义函数
 
 
文件传输 FTP

>> 连接
ftp_connect(host,port,timeout) - 建立连接
    ftp_ssl_connect(host,port,timeout) - SSL安全连接
    
    ftp_login(ftp_connection,username,password) - 登陆FTP
    ftp_raw(ftp_connection,command) - 发送命令
        ftp_exec(ftp_connection,command) - 执行命令(登陆后)
    ftp_pasv(ftp_connection,mode) - 是否被动模式
    ftp_systype(ftp_connection) - 远程机器系统
    ftp_get_option(ftp_connection,option) - 获取参数
        ftp_set_option(ftp_connection,option,value) - 设置选项
    ftp_close(ftp_connection) - 关闭连接,同 ftp_quit()
 
>> 目录
ftp_mkdir(ftp_connection,dir) - 建立目录
ftp_rmdir(ftp_connection,dir) - 删除目录
ftp_chdir(ftp_connection,dir) - 改变目录
ftp_cdup(ftp_connection) - 父目录
ftp_pwd(ftp_connection) - 当前路径
ftp_nlist(ftp_connection,dir) - 列目录
    ftp_rawlist(ftp_connection,dir,recursive) - 目录列表详情
 
>> 文件
ftp_put(ftp_connection,remote,local,mode,resume) - 上传文件
    ftp_fput(ftp_connection,remote,local,mode,resume) - 上传本地打开文件
    ftp_nb_put(ftp_connection,remote,local,mode,resume) - 异步上传
    ftp_nb_fput(ftp_connection,remote,local,mode,resume) - 异步上传本地打开文件
ftp_get(ftp_connection,local,remote,mode,resume) - 下载文件
    ftp_fget(ftp_connection,local,remote,mode,resume) - 下载到本地打开文件
    ftp_nb_get(ftp_connection,local,remote,mode,resume) - 异步下载
    ftp_nb_fget(ftp_connection,local,remote,mode,resume) - 异步下载到本地打开文件
ftp_delete(ftp_connection,path) - 删除文件
ftp_rename(ftp_connection,from,to) - 重命名
ftp_chmod(ftp_connection,mode,file) - 改变文件权限
ftp_size(ftp_connection,remote_file) - 文件大小
ftp_mdtm(ftp_connection,file) - 文件最后修改时间
 
 
HTTP

header(string,replace,http_response_code) - 发送HTTP报头
    headers_list() - 报头列表数组
    headers_sent() - 是否已发送报头
setcookie(name,value,expire,path,domain,secure) - 设置Cookie
数学 MATH

>> 算数
round() - 四舍五入
    ceil() - 向上取整
    floor() - 向下取整
max() - 返回最大值
    min() - 返回最小值
pow(x,y) - x的y次方
    sqrt() - 平方根
abs() - 绝对值
rand(min,max) - 返回随机整数
 
>> 进制
base_convert(number,frombase,tobase) - 任意进制转换
decbin() - 十进制 -> 二进制
    bindec(binary_string) - 二进制 -> 十进制
dechex() - 十进制 -> 十六进制
    hexdec() - 十六进制 -> 十进制
decoct() - 十进制 -> 八进制
    octdec() - 八进制 -> 十进制
 
>> 三角函数
cos() - 余弦
    acos() - 反余弦
sin() - 正弦
    asin() - 反正弦
tan() - 正切
    atan() -  - 反正切
 
 
MySQL

>> 连接
mysql_connect(server,user,pwd,newlink,clientflag) - 连接
    mysql_pconnect(server,user,pwd,clientflag) - 长连接
    mysql_close(connection) - 关闭
 
>> 查询
mysql_select_db(database,connection) - 选择数据库
mysql_query(sql) - 执行查询,返回资源句柄
mysql_fetch_array(data,array_type) - 查询, 返回数组
    mysql_fetch_assoc(data) - 返回关联数组
mysql_fetch_object(data) - 查询, 返回对象
mysql_num_rows(data) -  结果行数
 
>> 连接状态
mysql_ping(connection) - 检查连接, 断开则重连
mysql_thread_id(connection) - 当前连接ID
mysql_client_encoding(connection) - 当前字符集
mysql_list_dbs(connection) - 列出数据库
 
>> 上次操作
mysql_info(connection) - 上次查询的信息
mysql_affected_rows(connection) - 影响行数
mysql_insert_id(connection) - 上次插入的ID
mysql_errno(connection) - 上次错误ID
    mysql_error(connection) - 上次错误信息
 
 
输入输出 I/O

>> 打印
print_r(value)
    var_dump(value) - 带类型
    var_export(value) - 返回合法的PHP代码
0 0
原创粉丝点击