博客列表 >PHP常用函数

PHP常用函数

搁浅
搁浅原创
2023年11月26日 17:37:12111浏览

1、数组函数

  1. array(); 创建数组
  2. count(); 统计数组元素
  3. array_keys();获取数组key
  4. array_values; 获取数组值
  5. array_merge();合并数组
  6. array_combine();合并数组
  7. array_unique();数组唯一值
  8. sort();数组排序顺序
  9. rsort();倒序
  10. array_pop;删除数组末尾元素
  11. array_push();数组末尾添加元素
  12. array_shift();头部删除
  13. array_ushift();头部添加
  14. array_filter();回调函数过滤数组中的元素
  15. array_fill();填充数组
  16. array_diff();差集
  17. current();当前数组
  18. in_array();在数组
  19. is_array();判断
  20. array_search();搜索
  21. array_column();数组列
  22. array_key_exists();判断key是否存在

2、字符串函数

  1. sub_str();截取字符串
  2. str_replace();字符串替换
  3. strlen();长度
  4. strtoupper();转大写
  5. strtolower();转小写
  6. strstr();搜索
  7. strrev();翻转
  8. ucwords();首字母大写
  9. trim();去除空格
  10. strpos();查找第一次位置
  11. str_shuffle();随机打乱字符

3、时间格式是xxxx-x-xx xx:xx:xx

  1. date('Y-m-d H:i:s', strtotime('-1 days'));

4、常用的超全局变量(8个)

  1. $_GET ----->get传送方式
  2. $_POST ----->post传送方式
  3. $_REQUEST ----->可以接收到getpost两种方式的值
  4. $GLOBALS ----->所有的变量都放在里面
  5. $_FILE ----->上传文件使用
  6. $_SERVER ----->系统环境变量
  7. $_SESSION ----->会话控制的时候会用到
  8. $_COOKIE ----->会话控制的时候会用到

5、处理时间的常用函数?(重点看函数的‘参数’和‘返回值’)

  1. date_default_timezone_get()返回默认时区。
  2. date_default_timezone_set()设置默认时区。
  3. date()格式化本地时间/日期。
  4. getdate()返回日期/时间信息。
  5. gettimeofday()返回当前时间信息。
  6. microtime()返回当前时间的微秒数。
  7. mktime()返回一个日期的 Unix时间戳。
  8. strtotime()将任何英文文本的日期或时间描述解析为 Unix时间戳。
  9. time()返回当前时间的 Unix时间戳。
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议