搜索



字符串 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 ->

>> 加密

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 ->

>> 加密

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函数,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
简单地说明PHP会话的概念。简单地说明PHP会话的概念。Apr 26, 2025 am 12:09 AM

phpsessionstrackuserdataacrossmultiplepagerequestsusingauniqueIdStoredInacookie.here'showtomanageThemeffectionaly:1)startAsessionWithSessionwwithSession_start()和stordoredAtain $ _session.2)

您如何循环中存储在PHP会话中的所有值?您如何循环中存储在PHP会话中的所有值?Apr 26, 2025 am 12:06 AM

在PHP中,遍历会话数据可以通过以下步骤实现:1.使用session_start()启动会话。2.通过foreach循环遍历$_SESSION数组中的所有键值对。3.处理复杂数据结构时,使用is_array()或is_object()函数,并用print_r()输出详细信息。4.优化遍历时,可采用分页处理,避免一次性处理大量数据。这将帮助你在实际项目中更有效地管理和使用PHP会话数据。

说明如何使用会话进行用户身份验证。说明如何使用会话进行用户身份验证。Apr 26, 2025 am 12:04 AM

会话通过服务器端的状态管理机制实现用户认证。1)会话创建并生成唯一ID,2)ID通过cookies传递,3)服务器存储并通过ID访问会话数据,4)实现用户认证和状态管理,提升应用安全性和用户体验。

举一个如何在PHP会话中存储用户名的示例。举一个如何在PHP会话中存储用户名的示例。Apr 26, 2025 am 12:03 AM

Tostoreauser'snameinaPHPsession,startthesessionwithsession_start(),thenassignthenameto$_SESSION['username'].1)Usesession_start()toinitializethesession.2)Assigntheuser'snameto$_SESSION['username'].Thisallowsyoutoaccessthenameacrossmultiplepages,enhanc

哪些常见问题会导致PHP会话失败?哪些常见问题会导致PHP会话失败?Apr 25, 2025 am 12:16 AM

PHPSession失效的原因包括配置错误、Cookie问题和Session过期。1.配置错误:检查并设置正确的session.save_path。2.Cookie问题:确保Cookie设置正确。3.Session过期:调整session.gc_maxlifetime值以延长会话时间。

您如何在PHP中调试与会话相关的问题?您如何在PHP中调试与会话相关的问题?Apr 25, 2025 am 12:12 AM

在PHP中调试会话问题的方法包括:1.检查会话是否正确启动;2.验证会话ID的传递;3.检查会话数据的存储和读取;4.查看服务器配置。通过输出会话ID和数据、查看会话文件内容等方法,可以有效诊断和解决会话相关的问题。

如果session_start()被多次调用会发生什么?如果session_start()被多次调用会发生什么?Apr 25, 2025 am 12:06 AM

多次调用session_start()会导致警告信息和可能的数据覆盖。1)PHP会发出警告,提示session已启动。2)可能导致session数据意外覆盖。3)使用session_status()检查session状态,避免重复调用。

您如何在PHP中配置会话寿命?您如何在PHP中配置会话寿命?Apr 25, 2025 am 12:05 AM

在PHP中配置会话生命周期可以通过设置session.gc_maxlifetime和session.cookie_lifetime来实现。1)session.gc_maxlifetime控制服务器端会话数据的存活时间,2)session.cookie_lifetime控制客户端cookie的生命周期,设置为0时cookie在浏览器关闭时过期。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

mPDF

mPDF

mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

VSCode Windows 64位 下载

VSCode Windows 64位 下载

微软推出的免费、功能强大的一款IDE编辑器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

将Eclipse与SAP NetWeaver应用服务器集成。

安全考试浏览器

安全考试浏览器

Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。