Home Backend Development PHP Tutorial 100 most commonly used functions in PHP

100 most commonly used functions in PHP

May 08, 2020 am 10:49 AM
php function

The following list is the top 100 most commonly used PHP functions: they are the most commonly used functions that come with PHP.

The functions are named and ordered from 1 to 100. The other 4500 functions are not currently ranked. The following frequency list represents how often this function is used in PHP code: References come from 1900 PHP open source projects. They were reviewed using version 1.2.5 of the Exakat static analysis engine. The average is the number of times this function is called in a project. Some functions are used by wrappers, while others are main functions.

For example, 4 out of 5 projects use the count function, and the function is called about 150 times. It shows that it is very popular and widely used.

Click the function name to jump to the PHP documentation. There are some summary insights at the bottom of the Top 100 article.

排行 函数 频率 平均值
1 count 81.41 % 147.67
2 is_array 77.32 % 117.86
3 substr 74.62 % 142.92
4 in_array 74.16 % 79.55
5 explode 73.19 % 71.51
6 str_replace 72.32 % 101.05
7 implode 72.27 % 66.59
8 strlen 70.07 % 98.32
9 array_merge 69.46 % 64.01
10 strpos 67.98 % 78.18
11 preg_match 67.31 % 76.60
12 sprintf 67.16 % 119.46
13 trim 66.75 % 81.28
14 strtolower 65.99 % 59.62
15 file_exists 65.12 % 45.13
16 is_string 61.39 % 45.10
17 preg_replace 60.27 % 54.28
18 file_get_contents 59.96 % 20.71
19 array_key_exists 59.70 % 57.50
20 array_keys 59.35 % 39.59
21 dirname 56.44 % 54.84
22 function_exists 53.58 % 42.62
23 array_map 53.22 % 19.45
24 get_class 53.12 % 33.07
25 class_exists 52.50 % 23.13
26 is_object 51.94 % 35.35
27 time 51.79 % 41.42
28 json_encode 51.48 % 24.81
29 date 50.72 % 52.18
30 is_null 49.69 % 60.52
31 is_numeric 49.49 % 40.69
32 array_shift 49.49 % 23.28
33 defined 48.72 % 86.82
34 is_dir 48.57 % 22.86
35 json_decode 48.42 % 17.39
36 header 48.16 % 59.71
37 strtoupper 47.80 % 30.95
38 array_values 47.24 % 17.27
39 md5 46.88 % 23.74
40 method_exists 46.73 % 19.05
41 file_put_contents 46.68 % 12.49
42 rtrim 45.91 % 18.08
43 array_pop 45.51 % 20.60
44 unlink 44.59 % 23.55
45 basename 44.59 % 27.23
46 realpath 44.08 % 15.90
47 call_user_func 43.97 % 16.41
48 call_user_func_array 43.92 % 18.40
49 fopen 43.77 % 25.61
50 microtime 43.46 % 14.41
51 fclose 42.85 % 28.36
52 is_int 42.75 % 15.78
53 is_file 42.08 % 20.52
54 array_slice 41.83 % 13.20
55 preg_match_all 40.55 % 14.66
56 ucfirst 40.25 % 17.02
57 intval 40.19 % 88.13
58 str_repeat 40.14 % 19.51
59 serialize 40.14 % 22.05
60 array_filter 39.99 % 13.87
61 mkdir 39.79 % 11.17
62 is_callable 39.43 % 11.94
63 ltrim 39.17 % 10.90
64 ob_start 39.12 % 13.26
65 round 39.07 % 28.56
66 fwrite 38.97 % 23.39
67 array_unique 38.87 % 15.96
68 array_search 38.82 % 14.19
69 reset 38.71 % 20.79
70 array_unshift 38.10 % 10.32
71 parse_url 37.90 % 9.61
72 func_get_args 37.79 % 28.33
73 end 37.49 % 12.70
74 base64_encode 37.39 % 14.15
75 unserialize 37.18 % 18.35
76 max 36.98 % 22.88
77 preg_split 36.98 % 13.27
78 gettype 36.93 % 16.16
79 strrpos 36.67 % 11.95
80 version_compare 36.67 % 14.87
81 array_push 36.67 % 26.18
82 floor 36.11 % 18.78
83 strtotime 36.01 % 27.94
84 htmlspecialchars 35.96 % 51.08
85 ini_get 35.85 % 19.25
86 ini_set 35.60 % 14.49
87 chr 35.34 % 186.97
88 extension_loaded 35.29 % 14.17
89 is_bool 35.24 % 11.44
90 ksort 34.98 % 10.82
91 array_reverse 34.93 % 8.27
92 ord 34.73 % 53.17
93 uniqid 34.68 % 9.83
94 strtr 34.47 % 12.90
95 array_diff 34.32 % 11.13
96 error_reporting 34.17 % 8.99
97 ceil 33.35 % 11.99
98 urlencode 33.30 % 29.63
99 min 32.69 % 18.31
100 print_r 32.64 % 14.12

前 100 分析

最常用的 PHP 函数是字符串函数,然后是数组函数,接着是文件函数。 (运算函数不在此列主要是因为他们通常基于运算符)

每个函数的链接都指向其对应的文档,事实上许多函数经过发展以及获得了许多新特性,例如:count() 的第二个参数,dirname() 的第二个参数以及 preg_match() 和  str_replace() 接受数组作为参数等。有很多彩蛋。

以上 100 个函数没有近期要废弃的计划。

在非内置库中,mbstring 排名第一、curl 第二,然后是 gd、filter 和 iconv。

md5 是最常用的加密函数,其次是 Sha1 (#147)。

print_r 出现在 1/3 的项目代码里面的某处,任何地方 ...

由于 dirname(dirname(dirname())) 的调用,dirname 的使用频率非常高。

array、echo、print、empty、isset 这些没有纳入此排名,它们的使用度肯定是非常高的。

如下几个函数应该用运算符替代 : array_push, is_object, func_get_arg, chr, call_user_func。

相当多的调用是为了知道值的类型。

数据库函数没有在这里排名:他们经常使用类,但功能仍然很频繁。可能是另一个前 100 名?

相比写入文件 PHP 更多的应用于读取文件。它还解码 base64。

使用键排序比使用值或使用键更频繁。

通常使用 file_get_contents 读取文件,使用 fwrite 写入文件。

推荐教程:《PHP教程

The above is the detailed content of 100 most commonly used functions in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles