PHP常用函数(收集)
来源:互联网 发布:数控车床编程视频教学 编辑:程序博客网 时间:2024/06/07 02:34
>> 统计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)>> ASCIIord(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[] = $valuearray_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) - 返回对应的keyarray_values(array) - 返回所有valuearray_search(value,array,strict) - 搜索value,返回keyin_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和valuearray_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) - 当前keycurrent(array) - 当前value,同 pos(array)next(array) - 下一个valueprev(array) - 上一个valuereset(array) - 移到首部end(array) - 移到末尾日期时间 DATE & TIMEcheckdate(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) - 获取时间戳目录 DIRopendir(path,context) - 打开目录,返回句柄 readdir(handle) - 返回文件名 closedir(handle) - 关闭句柄 rewinddir(handle) - 重置句柄dir(directory) - 打开目录,返回对象,该对象有read(),rewind(),close() 3个方法文件 FILEclearstatcache() - 清除文件缓存状态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) - 文件inodefilesize(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 POSTis_uploaded_file(filename) - 文件是否通过HTTP POST上传move_uploaded_file(filename,newloc) - 移动上传的文件错误和异常 ERROR & EXCEPTIONdebug_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) - 异常处理函数过滤器 FILTERfilter_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)>> FilterSANITIZE(过滤) 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_FLOATVALIDATE(验证) FILTER_VALIDATE_BOOLEAN FILTER_VALIDATE_INT FILTER_VALIDATE_FLOAT FILTER_VALIDATE_URL FILTER_VALIDATE_EMAIL FILTER_VALIDATE_IP FILTER_VALIDATE_REGEXPFILTER_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) - 文件最后修改时间HTTPheader(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) - 当前连接IDmysql_client_encoding(connection) - 当前字符集mysql_list_dbs(connection) - 列出数据库>> 上次操作mysql_info(connection) - 上次查询的信息mysql_affected_rows(connection) - 影响行数mysql_insert_id(connection) - 上次插入的IDmysql_errno(connection) - 上次错误ID mysql_error(connection) - 上次错误信息输入输出 I/O>> 打印print_r(value) var_dump(value) - 带类型 var_export(value) - 返回合法的PHP代码Tags: php, 函数This entry was posted on 星期二, 十一月 5th, 2013 at 上午 4:09 and is filed under PHP. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.
原文
0 0
- 常用PHP函数收集
- php 常用函数收集
- PHP常用函数收集
- PHP常用函数(收集)
- 收藏PHP常用函数收集
- PHP常用函数(数组) 收集
- PHP常用字符串函数收集(60个)
- php常用函数收集并附解释说明
- php常用函数收集并附解释说明
- php常用函数收集并附解释说明
- 整理: php常用函数收集并附解释说明
- 数据库常用函数收集
- 常用js函数收集
- 常用js函数收集
- 常用js函数收集
- VC常用函数收集
- 常用函数收集
- java常用函数收集
- Mac下android_sdk配置环境变量
- 白话空间统计番外:再谈莫兰指数(Moran's I)
- Android Sensor流程
- GCD由浅入深学习
- navicat连接MSSQL和ORACLE
- PHP常用函数(收集)
- 登录案例_android
- JS 获取日期相差天数
- 最优装载方案
- libcurl增加HTTP header 和 POST之后获取返回数据
- (三)Boost库之字符串处理
- Android中圆形图的几种实现方式
- Servlet与Jsp的区别
- soledede-微积分-线性代数理解最小二乘法