您的位置 首页 php

PHP 中最常用的 100 个函数

PHP 静态分析引擎 Exakat 分析了 1900 个 PHP 开源项目,整理了最常用的 100 个 PHP 函数:

排行

函数

1

count

2

is_array

3

substr

4

in_array

5

explode

6

str_replace

7

implode

8

strlen

9

array_merge

10

strpos

11

preg_match

12

sprintf

13

trim

14

strtolower

15

file_exists

16

is_string

17

preg_replace

18

file_get_contents

19

array_key_ exists

20

array_keys

21

dirname

22

function_exists

23

array_map

24

get_class

25

class_exists

26

is_object

27

time

28

json _encode

29

date

30

is_null

31

is_numeric

32

array_shift

33

defined

34

is_dir

35

json_decode

36

header

37

strtoupper

38

array_values

39

md5

40

method_exists

41

file_put_contents

42

rtrim

43

array_pop

44

unlink

45

basename

46

realpath

47

call_user_func

48

call_user_func_array

49

fopen

50

microtime

51

fclose

52

is_int

53

is_file

54

array_slice

55

preg_match_all

56

ucfirst

57

intval

58

str_repeat

59

serialize

60

array_filter

61

mkdir

62

is_callable

63

ltrim

64

ob_start

65

round

66

fwrite

67

array_unique

68

array_search

69

reset

70

array_unshift

71

parse_url

72

func_get_args

73

end

74

base64_encode

75

unserialize

76

max

77

preg_split

78

gettype

79

strrpos

80

version_compare

81

array_push

82

floor

83

strtotime

84

htmlspecialchars

85

ini_get

86

ini_set

87

chr

88

extension_loaded

89

is_bool

90

ksort

91

array_reverse

92

ord

93

uniqid

94

strtr

95

array_diff

96

error_reporting

97

ceil

98

urlencode

99

min

100

print_r

从这最常用的 100 个 PHP 函数,总结一下:

  • 这 100 个函数近期都没有被废弃的计划,所以可以放心使用,并加强学习。
  • 最常用的是字符串函数,然后是数组函数和文件函数,有相当多的调用是为了知道值的类型。
  • md5 是最常用的加密函数,其次是 Sha1 (#147), print_r 出现在 1/3 的项目的代码中。
  • 由于 dirname(dirname(dirname())) 的调用方式, dirname 的排名变得异常的高。
  • 在非内置库中,mbstring 排名第一、curl 第二,然后是 gd、filter 和 iconv。
  • 数组中排序中使用键比使用值更频繁。
  • 读取文件的函数比写入文件的函数应用的多,另外通常使用 file_get_contents 读取文件,使用 fwrite 写入文件。
  • array , echo , print , empty , isset 和其他语言结构,因为不能算作 PHP 函数,所以没有纳入此排名,但是它们的使用度肯定是非常高的。
  • array_push , is_object , func_get_arg , chr , call_user_func 这些函数应该用运算符替代 。
  • 数据库函数没有在这里排名,因为经常使用的是类,但数据库的功能是使用度很高的。
  • 最后许多函数在新版中有了新的功能,比如 count() dirname() 有了第二个参数,以及 preg_match() str_replace() 接受数组作为参数等。

文章来源:智云一二三科技

文章标题:PHP 中最常用的 100 个函数

文章地址:https://www.zhihuclub.com/76503.shtml

关于作者: 智云科技

热门文章

网站地图