---
title: "The Top 100 PHP functions in 2024"
url: https://www.exakat.io/the-top-100-php-functions-in-2024/
date: 2024-12-16
modified: 2024-12-16
author: "dams"
description: "The 100 PHP functions that you have to know Here is the top 100 PHP functions : it is the list of the most often used PHP native functions. The..."
categories:
  - "Code auditing"
image: https://www.exakat.io/wp-content/uploads/2018/05/keys.320.jpg
word_count: 888
---

# The Top 100 PHP functions in 2024

# The 100 PHP functions that you have to know

Here is the top 100 PHP functions : it is the list of the most often used PHP native functions.

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...). They were audited with [Exakat static analysis engine](https://www.exakat.io/), version 2.4.7. The average is the number of time the function is called within one project.

For example, 4 project out of 5 uses the [count()](https://php.net/count) function, and when used, [count()](https://php.net/count) is called around 61 times. It is both a popular and heavily used function. On the other hand, [dirname()](http://php.net/dirname) is popular but rarely used (56% for 13 usages)

Click on the link to go to the documentation. Some insight at the bottom of the top 100.

 

## The 100 most popular PHP functions

| 1 | [file_exists](https://www.php.net/manual/en/function.file-exists.php) | 66.05% | 18 |
| --- | --------------------------------------------------------------------- | ------ | --- |
| 2 | [count](https://www.php.net/manual/en/function.count.php) | 63.67% | 87 |
| 3 | [str_replace](https://www.php.net/manual/en/function.str-replace.php) | 63.58% | 51 |
| 4 | [implode](https://www.php.net/manual/en/function.implode.php) | 62.72% | 48 |
| 5 | [substr](https://www.php.net/manual/en/function.substr.php) | 60.30% | 70 |
| 6 | [array_merge](https://www.php.net/manual/en/function.array-merge.php) | 60.02% | 51 |
| 7 | [sprintf](https://www.php.net/manual/en/function.sprintf.php) | 59.89% | 103 |
| 8 | [dirname](https://www.php.net/manual/en/function.dirname.php) | 58.91% | 17 |
| 9 | [explode](https://www.php.net/manual/en/function.explode.php) | 58.30% | 37 |
| 10 | [in_array](https://www.php.net/manual/en/function.in-array.php) | 58.27% | 49 |
| 11 | [strpos](https://www.php.net/manual/en/function.strpos.php) | 58.08% | 31 |
| 12 | [is_array](https://www.php.net/manual/en/function.is-array.php) | 58.05% | 73 |
| 13 | [strlen](https://www.php.net/manual/en/function.strlen.php) | 56.37% | 45 |
| 14 | [array_key_exists](https://www.php.net/manual/en/function.array-key-exists.php) | 54.87% | 88 |
| 15 | [array_keys](https://www.php.net/manual/en/function.array-keys.php) | 54.72% | 23 |
| 16 | [preg_match](https://www.php.net/manual/en/function.preg-match.php) | 52.02% | 40 |
| 17 | [file_get_contents](https://www.php.net/manual/en/function.file-get-contents.php) | 51.76% | 11 |
| 18 | [trim](https://www.php.net/manual/en/function.trim.php) | 48.49% | 37 |
| 19 | [is_string](https://www.php.net/manual/en/function.is-string.php) | 48.46% | 27 |
| 20 | [array_values](https://www.php.net/manual/en/function.array-values.php) | 48.46% | 10 |
| 21 | [is_file](https://www.php.net/manual/en/function.is-file.php) | 46.90% | 7 |
| 22 | [method_exists](https://www.php.net/manual/en/function.method-exists.php) | 46.62% | 11 |
| 23 | [array_map](https://www.php.net/manual/en/function.array-map.php) | 46.11% | 17 |
| 24 | [file_put_contents](https://www.php.net/manual/en/function.file-put-contents.php) | 46.11% | 7 |
| 25 | [strtolower](https://www.php.net/manual/en/function.strtolower.php) | 45.44% | 26 |
| 26 | [function_exists](https://www.php.net/manual/en/function.function-exists.php) | 44.97% | 21 |
| 27 | [preg_replace](https://www.php.net/manual/en/function.preg-replace.php) | 44.40% | 23 |
| 28 | [defined](https://www.php.net/manual/en/function.defined.php) | 43.44% | 27 |
| 29 | [is_dir](https://www.php.net/manual/en/function.is-dir.php) | 41.70% | 8 |
| 30 | [json_decode](https://www.php.net/manual/en/function.json-decode.php) | 41.54% | 10 |
| 31 | [json_encode](https://www.php.net/manual/en/function.json-encode.php) | 41.16% | 15 |
| 32 | [call_user_func](https://www.php.net/manual/en/function.call-user-func.php) | 41.06% | 5 |
| 33 | [array_filter](https://www.php.net/manual/en/function.array-filter.php) | 41.00% | 10 |
| 34 | [strtr](https://www.php.net/manual/en/function.strtr.php) | 40.55% | 6 |
| 35 | [fwrite](https://www.php.net/manual/en/function.fwrite.php) | 40.08% | 7 |
| 36 | [rtrim](https://www.php.net/manual/en/function.rtrim.php) | 39.85% | 8 |
| 37 | [strrpos](https://www.php.net/manual/en/function.strrpos.php) | 39.54% | 4 |
| 38 | [call_user_func_array](https://www.php.net/manual/en/function.call-user-func-array.php) | 39.41% | 4 |
| 39 | [filter_var](https://www.php.net/manual/en/function.filter-var.php) | 39.25% | 3 |
| 40 | [class_exists](https://www.php.net/manual/en/function.class-exists.php) | 39.22% | 17 |
| 41 | [header](https://www.php.net/manual/en/function.header.php) | 38.71% | 11 |
| 42 | [array_flip](https://www.php.net/manual/en/function.array-flip.php) | 38.62% | 3 |
| 43 | [realpath](https://www.php.net/manual/en/function.realpath.php) | 38.11% | 6 |
| 44 | [ini_get](https://www.php.net/manual/en/function.ini-get.php) | 38.01% | 6 |
| 45 | [get_class](https://www.php.net/manual/en/function.get-class.php) | 36.01% | 14 |
| 46 | [is_object](https://www.php.net/manual/en/function.is-object.php) | 35.03% | 15 |
| 47 | [unlink](https://www.php.net/manual/en/function.unlink.php) | 34.96% | 8 |
| 48 | [trigger_error](https://www.php.net/manual/en/function.trigger-error.php) | 34.84% | 8 |
| 49 | [array_shift](https://www.php.net/manual/en/function.array-shift.php) | 34.71% | 8 |
| 50 | [is_int](https://www.php.net/manual/en/function.is-int.php) | 33.76% | 7 |
| 51 | [spl_autoload_register](https://www.php.net/manual/en/function.spl-autoload-register.php) | 33.57% | 1 |
| 52 | [is_numeric](https://www.php.net/manual/en/function.is-numeric.php) | 32.93% | 13 |
| 53 | [strtoupper](https://www.php.net/manual/en/function.strtoupper.php) | 32.93% | 9 |
| 54 | [mkdir](https://www.php.net/manual/en/function.mkdir.php) | 32.93% | 4 |
| 55 | [array_pop](https://www.php.net/manual/en/function.array-pop.php) | 32.52% | 7 |
| 56 | [ltrim](https://www.php.net/manual/en/function.ltrim.php) | 31.95% | 5 |
| 57 | [headers_sent](https://www.php.net/manual/en/function.headers-sent.php) | 31.95% | 2 |
| 58 | [fopen](https://www.php.net/manual/en/function.fopen.php) | 31.88% | 8 |
| 59 | [array_unique](https://www.php.net/manual/en/function.array-unique.php) | 31.79% | 6 |
| 60 | [str_repeat](https://www.php.net/manual/en/function.str-repeat.php) | 31.47% | 9 |
| 61 | [basename](https://www.php.net/manual/en/function.basename.php) | 31.25% | 6 |
| 62 | [array_slice](https://www.php.net/manual/en/function.array-slice.php) | 30.39% | 5 |
| 63 | [fclose](https://www.php.net/manual/en/function.fclose.php) | 29.91% | 7 |
| 64 | [time](https://www.php.net/manual/en/function.time.php) | 29.47% | 16 |
| 65 | [is_callable](https://www.php.net/manual/en/function.is-callable.php) | 29.37% | 5 |
| 66 | [preg_match_all](https://www.php.net/manual/en/function.preg-match-all.php) | 29.28% | 4 |
| 67 | [is_bool](https://www.php.net/manual/en/function.is-bool.php) | 29.15% | 3 |
| 68 | [microtime](https://www.php.net/manual/en/function.microtime.php) | 28.74% | 5 |
| 69 | [spl_autoload_unregister](https://www.php.net/manual/en/function.spl-autoload-unregister.php) | 28.71% | 1 |
| 70 | [var_export](https://www.php.net/manual/en/function.var-export.php) | 28.61% | 4 |
| 71 | [array_unshift](https://www.php.net/manual/en/function.array-unshift.php) | 28.58% | 3 |
| 72 | [max](https://www.php.net/manual/en/function.max.php) | 28.42% | 7 |
| 73 | [array_search](https://www.php.net/manual/en/function.array-search.php) | 28.29% | 4 |
| 74 | [apcu_fetch](https://www.php.net/manual/en/function.apcu-fetch.php) | 28.29% | 0 |
| 75 | [extension_loaded](https://www.php.net/manual/en/function.extension-loaded.php) | 28.20% | 4 |
| 76 | [getcwd](https://www.php.net/manual/en/function.getcwd.php) | 28.17% | 2 |
| 77 | [preg_split](https://www.php.net/manual/en/function.preg-split.php) | 28.14% | 4 |
| 78 | [reset](https://www.php.net/manual/en/function.reset.php) | 28.10% | 6 |
| 79 | [end](https://www.php.net/manual/en/function.end.php) | 28.04% | 4 |
| 80 | [gettype](https://www.php.net/manual/en/function.gettype.php) | 28.04% | 4 |
| 81 | [stream_resolve_include_path](https://www.php.net/manual/en/function.stream-resolve-include-path.php) | 27.85% | 0 |
| 82 | [md5](https://www.php.net/manual/en/function.md5.php) | 27.72% | 6 |
| 83 | [getenv](https://www.php.net/manual/en/function.getenv.php) | 27.66% | 6 |
| 84 | [apcu_add](https://www.php.net/manual/en/function.apcu-add.php) | 27.41% | 0 |
| 85 | [ucfirst](https://www.php.net/manual/en/function.ucfirst.php) | 27.34% | 7 |
| 86 | [ksort](https://www.php.net/manual/en/function.ksort.php) | 27.31% | 3 |
| 87 | [date](https://www.php.net/manual/en/function.date.php) | 27.18% | 14 |
| 88 | [is_null](https://www.php.net/manual/en/function.is-null.php) | 26.90% | 27 |
| 89 | [parse_url](https://www.php.net/manual/en/function.parse-url.php) | 26.61% | 3 |
| 90 | [preg_quote](https://www.php.net/manual/en/function.preg-quote.php) | 26.61% | 4 |
| 91 | [array_reverse](https://www.php.net/manual/en/function.array-reverse.php) | 26.58% | 3 |
| 92 | [array_diff](https://www.php.net/manual/en/function.array-diff.php) | 26.45% | 4 |
| 93 | [base64_encode](https://www.php.net/manual/en/function.base64-encode.php) | 26.14% | 4 |
| 94 | [version_compare](https://www.php.net/manual/en/function.version-compare.php) | 26.04% | 4 |
| 95 | [preg_replace_callback](https://www.php.net/manual/en/function.preg-replace-callback.php) | 25.91% | 4 |
| 96 | [current](https://www.php.net/manual/en/function.current.php) | 25.25% | 3 |
| 97 | [round](https://www.php.net/manual/en/function.round.php) | 25.25% | 7 |
| 98 | [min](https://www.php.net/manual/en/function.min.php) | 25.15% | 4 |
| 99 | [serialize](https://www.php.net/manual/en/function.serialize.php) | 25.02% | 6 |

## Top 100 insights

- The most commonly used PHP functions are [string](https://www.php.net/manual/en/language.types.string.php) functions, and then [arrays](https://www.php.net/manual/en/language.types.array.php), then [files](https://www.php.net/manual/en/ref.filesystem.php).

Math functions are probably out of the ranking, as they are mostly based on operators
- Databases functions (pdo, mysqli*, pg_*...) are probably out of scope, as they are based on classes or components

- No recently deprecated function is in the top 100.
- Usage of [composer](https://getcomposer.org/) may also reduce the need for some native function, by federating them in a component, and reducing their overall usage. For example, [monolog](https://github.com/Seldaek/monolog) may use [log](https://php.net/log)() and reduce its usage across the Open Source community.
- Extension that makes it to the top 100 : [filter](https://www.php.net/manual/en/book.filter.php), [json](https://www.php.net/manual/json/book.filter.php), [apcu](https://www.php.net/manual/apcu/book.filter.php).
- json_encode() and json_decode() are now used with the same exact frequency, or almost.
- `md5` is the only widely used crypto function. hash() is the next, in 159th position (not shown). This must change!
- Debug functions, such as print_r() or var_dump() are out of the top 100. var_export() is a more ambiguous case.
- `array`, `echo`, `print`, `empty`, `isset` and other language constructs were not counted as functions in this ranking. They are probably trusting the first ranks anyway.
- Several functions could and should be replaced by operators : `is_object()`, call_user_func(), call_user_func_array()
- max() is more often than min()
- Types are still a major concern of PHP code : is it a string? is it an object? No, it's a resource!

Type system may go a long way, but there are still return values that needs testing.

- There is also a [PHP top 100 for the PHP classes](https://www.exakat.io/en/top-100-php-classes-that-you-should-know/). Well,

## Challenges

If you are learning PHP, it is a good idea to review the 100 functions ranked here : they are the features you'll find the most often when landing on a coding team. They are not the only ones, but you'll be less surprised when meeting them.

## More details?

Follow us on [BlueSky](https://bsky.app/profile/dseguy.bsky.social) or [mastodon](https://phpc.social/@dseguy) if you want more details, more stats