Top PHP Functions
If you are a PHP developer, you must know the Top 100 PHP Functions deeply.
The 100 PHP functions that you have to know (2022)
Here is the top 100 PHP functions: it is the list of the most often used PHP native functions.
Why this repository? As a lead developer in the team, I am teaching the functions to my team members deeply.
Where is the Data?
The functions are named, and ranked from 1 to 100. The other 4500 functions are not ranked here.
The frequency column represents how often this function is used across PHP code repositories: the reference corpus is a list of 2500 PHP Open Source projects (top 1000 composer, github/gitlab/gitee public repo, downloaded archives…).
PHP Functions
Rank | Function | Frequency | Average |
---|---|---|---|
1 | file_exists | 62.80% | 13 |
2 | str_replace | 58.20% | 33 |
3 | implode | 57.31% | 35 |
4 | count | 56.42% | 61 |
5 | dirname | 56.38% | 13 |
6 | substr | 55.84% | 53 |
7 | sprintf | 55.26% | 80 |
8 | strpos | 55.07% | 24 |
9 | array_merge | 54.80% | 35 |
10 | in_array | 51.39% | 33 |
11 | explode | 51.35% | 26 |
12 | strlen | 50.97% | 35 |
13 | is_array | 50.73% | 46 |
14 | array_key_exists | 49.54% | 28 |
15 | array_keys | 49.27% | 16 |
16 | preg_match | 46.52% | 28 |
17 | file_get_contents | 46.48% | 8 |
18 | is_file | 44.43% | 6 |
19 | array_values | 42.81% | 7 |
20 | file_put_contents | 42.46% | 4 |
21 | trim | 41.57% | 25 |
22 | method_exists | 41.49% | 8 |
23 | defined | 40.87% | 19 |
24 | is_string | 40.76% | 20 |
25 | function_exists | 40.29% | 20 |
26 | array_map | 39.33% | 12 |
27 | preg_replace | 39.02% | 17 |
28 | strtolower | 38.94% | 19 |
29 | is_dir | 38.67% | 6 |
30 | strtr | 38.01% | 5 |
31 | call_user_func | 37.01% | 4 |
32 | strrpos | 36.70% | 4 |
33 | call_user_func_array | 36.43% | 3 |
34 | array_flip | 35.89% | 2 |
35 | fwrite | 35.89% | 4 |
36 | rtrim | 35.69% | 6 |
37 | filter_var | 35.65% | 2 |
38 | ini_get | 35.15% | 5 |
39 | json_decode | 34.76% | 7 |
40 | array_filter | 34.76% | 7 |
41 | realpath | 34.15% | 4 |
42 | header | 34.07% | 7 |
43 | class_exists | 34.03% | 12 |
44 | json_encode | 33.49% | 9 |
45 | trigger_error | 32.95% | 5 |
46 | get_class | 32.95% | 13 |
47 | spl_autoload_register | 32.10% | 1 |
48 | unlink | 30.43% | 5 |
49 | headers_sent | 29.78% | 1 |
50 | is_object | 29.31% | 11 |
51 | mkdir | 29.20% | 2 |
52 | array_shift | 28.69% | 6 |
53 | spl_autoload_unregister | 28.54% | 1 |
54 | apcu_fetch | 28.23% | 0 |
55 | array_pop | 28.11% | 5 |
56 | stream_resolve_include_path | 27.84% | 0 |
57 | is_int | 27.65% | 5 |
58 | apcu_add | 27.57% | 0 |
59 | getcwd | 27.49% | 1 |
60 | strtoupper | 27.42% | 6 |
61 | is_numeric | 26.95% | 9 |
62 | array_unique | 26.91% | 4 |
63 | ltrim | 26.60% | 4 |
64 | basename | 26.57% | 4 |
65 | str_repeat | 26.26% | 7 |
66 | fopen | 25.91% | 6 |
67 | array_slice | 24.94% | 3 |
68 | getenv | 24.94% | 4 |
69 | var_export | 24.71% | 3 |
70 | preg_match_all | 24.67% | 3 |
71 | is_callable | 24.48% | 4 |
72 | reset | 24.44% | 4 |
73 | preg_split | 24.40% | 3 |
74 | fclose | 24.36% | 5 |
75 | array_unshift | 24.25% | 3 |
76 | gettype | 24.21% | 4 |
77 | end | 23.90% | 3 |
78 | array_search | 23.82% | 3 |
79 | max | 23.78% | 5 |
80 | extension_loaded | 23.59% | 3 |
81 | is_bool | 23.55% | 2 |
82 | version_compare | 22.82% | 3 |
83 | preg_quote | 22.78% | 3 |
84 | time | 22.70% | 9 |
85 | ucfirst | 22.66% | 4 |
86 | ksort | 22.66% | 2 |
87 | preg_replace_callback | 22.54% | 3 |
88 | md5 | 22.51% | 4 |
89 | array_reverse | 22.47% | 2 |
90 | array_diff | 22.12% | 2 |
91 | is_readable | 22.00% | 1 |
92 | microtime | 21.96% | 4 |
93 | copy | 21.81% | 1 |
94 | parse_url | 21.81% | 2 |
95 | is_null | 21.50% | 17 |
96 | base64_encode | 21.42% | 3 |
97 | current | 21.38% | 2 |
98 | is_resource | 21.08% | 3 |
99 | serialize | 20.77% | 4 |
100 | key | 20.57% | 2 |