I worked for a while until I found the answer to the most used PHP functions in the most popular CMS, but the work was worth it. At least I got an idea of how PHP uses a server’s resources and possibly optimizing the use of those functions that “eat” most of the computing power!
The CMS considered were the following: Wordpress, Drupal, Magento, Vanilla, Bbpress, Phpbb3, Typo3, Joomla, Serendipity, Impresspages, Dotclear, Smf, Minibb, Mindtouch, Mediawiki, Docuwiki, Phpwiki, Pmpwiki… and The versions used were those from 2019-2020.
* I will return in a few subsequent posts with an individual statistic on CMS, a top 100 for the most used functions for each CMS.
Rank | Function | Count | % |
---|---|---|---|
1 | isset | 39447 | 12.63 |
2 | empty | 18201 | 5.83 |
3 | sprintf | 12952 | 4.15 |
4 | count | 12572 | 4.03 |
5 | substr | 11342 | 3.63 |
6 | is_array | 8736 | 2.8 |
7 | implode | 7453 | 2.39 |
8 | unset | 7380 | 2.36 |
9 | strlen | 6572 | 2.1 |
10 | array_merge | 6546 | 2.1 |
11 | strpos | 6270 | 2.01 |
12 | explode | 6199 | 1.99 |
13 | str_replace | 6194 | 1.98 |
14 | in_array | 5858 | 1.88 |
15 | trim | 5785 | 1.85 |
16 | array_keys | 4853 | 1.55 |
17 | preg_match | 4740 | 1.52 |
18 | preg_replace | 3858 | 1.24 |
19 | strtolower | 3746 | 1.2 |
20 | htmlspecialchars | 3709 | 1.19 |
21 | dirname | 2686 | 0.86 |
22 | time | 2411 | 0.77 |
23 | list | 2375 | 0.76 |
24 | array_key_exists | 2343 | 0.75 |
25 | is_string | 2143 | 0.69 |
26 | array_map | 1926 | 0.62 |
27 | get_class | 1797 | 0.58 |
28 | file_exists | 1752 | 0.56 |
29 | array_values | 1650 | 0.53 |
30 | file_get_contents | 1579 | 0.51 |
31 | reset | 1572 | 0.5 |
32 | is_null | 1567 | 0.5 |
33 | is_object | 1487 | 0.48 |
34 | array_shift | 1472 | 0.47 |
35 | array_unique | 1433 | 0.46 |
36 | trigger_error | 1398 | 0.45 |
37 | function_exists | 1390 | 0.45 |
38 | array_filter | 1318 | 0.42 |
39 | defined | 1312 | 0.42 |
40 | json_encode | 1311 | 0.42 |
41 | intval | 1304 | 0.42 |
42 | date | 1294 | 0.41 |
43 | strtoupper | 1280 | 0.41 |
44 | chr | 1271 | 0.41 |
45 | is_numeric | 1234 | 0.4 |
46 | md5 | 1231 | 0.39 |
47 | serialize | 1228 | 0.39 |
48 | array_pop | 1198 | 0.38 |
49 | ord | 1160 | 0.37 |
50 | array_diff | 1085 | 0.35 |
51 | strtr | 996 | 0.32 |
52 | define | 970 | 0.31 |
53 | rtrim | 927 | 0.3 |
54 | json_decode | 906 | 0.29 |
55 | pack | 897 | 0.29 |
56 | method_exists | 882 | 0.28 |
57 | basename | 873 | 0.28 |
58 | current | 855 | 0.27 |
59 | max | 839 | 0.27 |
60 | delete | 823 | 0.26 |
61 | microtime | 810 | 0.26 |
62 | func_get_args | 810 | 0.26 |
63 | round | 805 | 0.26 |
64 | unserialize | 794 | 0.25 |
65 | ltrim | 786 | 0.25 |
66 | call_user_func | 779 | 0.25 |
67 | str_repeat | 770 | 0.25 |
68 | strtotime | 749 | 0.24 |
69 | preg_quote | 723 | 0.23 |
70 | array_slice | 721 | 0.23 |
71 | class_exists | 706 | 0.23 |
72 | join | 700 | 0.22 |
73 | min | 687 | 0.22 |
74 | array_flip | 679 | 0.22 |
75 | call_user_func_array | 665 | 0.21 |
76 | realpath | 663 | 0.21 |
77 | ini_get | 657 | 0.21 |
78 | extract | 641 | 0.21 |
79 | ucfirst | 641 | 0.21 |
80 | unpack | 636 | 0.2 |
81 | fopen | 633 | 0.2 |
82 | base64_encode | 629 | 0.2 |
83 | compact | 608 | 0.19 |
84 | preg_split | 602 | 0.19 |
85 | key | 599 | 0.19 |
86 | is_dir | 588 | 0.19 |
87 | preg_replace_callback | 587 | 0.19 |
88 | parse_url | 582 | 0.19 |
89 | array_search | 578 | 0.19 |
90 | sizeof | 568 | 0.18 |
91 | header | 554 | 0.18 |
92 | version_compare | 547 | 0.18 |
93 | end | 542 | 0.17 |
94 | preg_match_all | 536 | 0.17 |
95 | mt_rand | 531 | 0.17 |
96 | floor | 528 | 0.17 |
97 | exit | 526 | 0.17 |
98 | fclose | 520 | 0.17 |
99 | urlencode | 516 | 0.17 |
100 | is_callable | 515 | 0.16 |
101 | array_reverse | 501 | 0.16 |
102 | fread | 489 | 0.16 |
103 | assert | 475 | 0.15 |
104 | sort | 474 | 0.15 |
105 | strip_tags | 458 | 0.15 |
106 | uniqid | 454 | 0.15 |
107 | die | 448 | 0.14 |
108 | ksort | 443 | 0.14 |
109 | rand | 438 | 0.14 |
110 | pathinfo | 437 | 0.14 |
111 | array_intersect_key | 436 | 0.14 |
112 | strrpos | 434 | 0.14 |
113 | array_replace_recursive | 432 | 0.14 |
114 | rawurlencode | 421 | 0.13 |
115 | stripos | 418 | 0.13 |
116 | array_unshift | 411 | 0.13 |
117 | abs | 409 | 0.13 |
118 | is_file | 403 | 0.13 |
119 | array_intersect | 400 | 0.13 |
120 | var_export | 400 | 0.13 |
121 | hexdec | 395 | 0.13 |
122 | fwrite | 391 | 0.13 |
123 | ceil | 384 | 0.12 |
124 | file_put_contents | 375 | 0.12 |
125 | is_int | 371 | 0.12 |
126 | str_pad | 365 | 0.12 |
127 | next | 357 | 0.11 |
128 | strstr | 354 | 0.11 |
129 | array_diff_key | 351 | 0.11 |
130 | printf | 340 | 0.11 |
131 | substr_count | 335 | 0.11 |
132 | gettype | 328 | 0.11 |
133 | unlink | 328 | 0.11 |
134 | addslashes | 322 | 0.1 |
135 | base64_decode | 318 | 0.1 |
136 | http_build_query | 315 | 0.1 |
137 | print_r | 309 | 0.1 |
138 | curl_setopt | 301 | 0.1 |
139 | is_resource | 301 | 0.1 |
140 | filesize | 301 | 0.1 |
141 | gmdate | 300 | 0.1 |
142 | mb_strtolower | 298 | 0.1 |
143 | user_error | 296 | 0.09 |
144 | array_combine | 287 | 0.09 |
145 | strftime | 286 | 0.09 |
146 | extension_loaded | 286 | 0.09 |
147 | is_a | 284 | 0.09 |
148 | strval | 276 | 0.09 |
149 | array_column | 274 | 0.09 |
150 | substr_replace | 263 | 0.08 |
151 | strcasecmp | 262 | 0.08 |
152 | range | 257 | 0.08 |
153 | number_format | 250 | 0.08 |
154 | fgets | 248 | 0.08 |
155 | array_push | 243 | 0.08 |
156 | is_bool | 243 | 0.08 |
157 | urldecode | 242 | 0.08 |
158 | file | 238 | 0.08 |
159 | mb_substr | 232 | 0.07 |
160 | sha1 | 230 | 0.07 |
161 | ob_start | 229 | 0.07 |
162 | array_merge_recursive | 226 | 0.07 |
163 | echo | 220 | 0.07 |
164 | iterator_to_array | 220 | 0.07 |
165 | mb_strlen | 220 | 0.07 |
166 | mkdir | 219 | 0.07 |
167 | glob | 216 | 0.07 |
168 | ini_set | 209 | 0.07 |
169 | getenv | 209 | 0.07 |
170 | array_replace | 208 | 0.07 |
171 | array_walk | 206 | 0.07 |
172 | get_object_vars | 202 | 0.06 |
173 | flush | 196 | 0.06 |
174 | hash | 195 | 0.06 |
175 | ob_get_contents | 193 | 0.06 |
176 | copy | 192 | 0.06 |
177 | filemtime | 190 | 0.06 |
178 | rewind | 189 | 0.06 |
179 | ob_get_clean | 187 | 0.06 |
180 | strncmp | 183 | 0.06 |
181 | pow | 183 | 0.06 |
182 | htmlspecialchars_decode | 182 | 0.06 |
183 | ucwords | 179 | 0.06 |
184 | nl2br | 175 | 0.06 |
185 | filter_var | 174 | 0.06 |
186 | array_splice | 173 | 0.06 |
187 | rawurldecode | 172 | 0.06 |
188 | uasort | 171 | 0.05 |
189 | mktime | 170 | 0.05 |
190 | property_exists | 169 | 0.05 |
191 | parse_str | 167 | 0.05 |
192 | usort | 165 | 0.05 |
193 | fputs | 164 | 0.05 |
194 | asort | 164 | 0.05 |
195 | set_error_handler | 164 | 0.05 |
196 | is_scalar | 163 | 0.05 |
197 | log | 161 | 0.05 |
198 | stripslashes | 157 | 0.05 |
199 | error_reporting | 155 | 0.05 |
200 | spl_object_hash | 151 | 0.05 |
201 | strcmp | 151 | 0.05 |
202 | is_writable | 150 | 0.05 |
203 | array_fill_keys | 150 | 0.05 |
204 | main | 150 | 0.05 |
205 | rename | 150 | 0.05 |
206 | html_entity_decode | 149 | 0.05 |
207 | dechex | 147 | 0.05 |
208 | ob_end_clean | 145 | 0.05 |
209 | readdir | 145 | 0.05 |
210 | chmod | 144 | 0.05 |
211 | eval | 143 | 0.05 |
212 | str_split | 139 | 0.04 |
213 | debug_backtrace | 137 | 0.04 |
214 | phpversion | 137 | 0.04 |
215 | constant | 136 | 0.04 |
216 | is_readable | 134 | 0.04 |
217 | session_id | 134 | 0.04 |
218 | strtok | 132 | 0.04 |
219 | array_reduce | 127 | 0.04 |
220 | strcspn | 126 | 0.04 |
221 | array_fill | 126 | 0.04 |
222 | bin2hex | 126 | 0.04 |
223 | sleep | 126 | 0.04 |
224 | htmlentities | 126 | 0.04 |
225 | each | 126 | 0.04 |
226 | restore_error_handler | 125 | 0.04 |
227 | stristr | 124 | 0.04 |
228 | getimagesize | 123 | 0.04 |
229 | strspn | 123 | 0.04 |
230 | is_subclass_of | 119 | 0.04 |
231 | libxml_use_internal_errors | 116 | 0.04 |
232 | setlocale | 114 | 0.04 |
233 | exec | 114 | 0.04 |
234 | iconv | 113 | 0.04 |
235 | mb_convert_encoding | 112 | 0.04 |
236 | array_change_key_case | 112 | 0.04 |
237 | preg_grep | 111 | 0.04 |
238 | 111 | 0.04 | |
239 | tempnam | 109 | 0.03 |
240 | simplexml_load_file | 109 | 0.03 |
241 | touch | 109 | 0.03 |
242 | imagesy | 103 | 0.03 |
243 | strrev | 101 | 0.03 |
244 | imagesx | 101 | 0.03 |
245 | fseek | 100 | 0.03 |
246 | clearstatcache | 100 | 0.03 |
247 | escapeshellarg | 95 | 0.03 |
248 | array_chunk | 95 | 0.03 |
249 | strrchr | 95 | 0.03 |
250 | addcslashes | 94 | 0.03 |
251 | opendir | 94 | 0.03 |
252 | func_num_args | 93 | 0.03 |
253 | imagecreatetruecolor | 93 | 0.03 |
254 | imagecolorallocate | 91 | 0.03 |
255 | getcwd | 91 | 0.03 |
256 | lcfirst | 91 | 0.03 |
257 | memory_get_usage | 88 | 0.03 |
258 | feof | 87 | 0.03 |
259 | array_sum | 86 | 0.03 |
260 | scandir | 85 | 0.03 |
261 | floatval | 82 | 0.03 |
262 | func_get_arg | 81 | 0.03 |
263 | simplexml_load_string | 81 | 0.03 |
264 | stream_get_contents | 80 | 0.03 |
265 | flock | 80 | 0.03 |
266 | crypt | 80 | 0.03 |
267 | vsprintf | 80 | 0.03 |
268 | curl_exec | 79 | 0.03 |
269 | random_bytes | 79 | 0.03 |
270 | closedir | 79 | 0.03 |
271 | chdir | 78 | 0.02 |
272 | is_integer | 77 | 0.02 |
273 | curl_init | 77 | 0.02 |
274 | imagedestroy | 77 | 0.02 |
275 | mb_internal_encoding | 75 | 0.02 |
276 | curl_getinfo | 74 | 0.02 |
277 | ctype_digit | 72 | 0.02 |
278 | rmdir | 71 | 0.02 |
279 | is_float | 70 | 0.02 |
280 | ftell | 70 | 0.02 |
281 | utf8_decode | 69 | 0.02 |
282 | hash_hmac | 69 | 0.02 |
283 | array_pad | 69 | 0.02 |
284 | sys_get_temp_dir | 69 | 0.02 |
285 | get_class_methods | 67 | 0.02 |
286 | gmmktime | 66 | 0.02 |
287 | class_implements | 66 | 0.02 |
288 | imagefilledrectangle | 66 | 0.02 |
289 | random_int | 64 | 0.02 |
290 | crc32 | 63 | 0.02 |
291 | interface_exists | 62 | 0.02 |
292 | mb_strtoupper | 62 | 0.02 |
293 | usleep | 62 | 0.02 |
294 | date_default_timezone_get | 61 | 0.02 |
295 | stat | 60 | 0.02 |
296 | stream_get_meta_data | 59 | 0.02 |
297 | imagealphablending | 59 | 0.02 |
298 | headers_sent | 59 | 0.02 |
299 | libxml_disable_entity_loader | 58 | 0.02 |
300 | utf8_encode | 58 | 0.02 |
301 | var_dump | 57 | 0.02 |
302 | json_last_error | 56 | 0.02 |
303 | spl_autoload_register | 56 | 0.02 |
304 | krsort | 55 | 0.02 |
305 | get_parent_class | 55 | 0.02 |
306 | chunk_split | 54 | 0.02 |
307 | token_get_all | 53 | 0.02 |
308 | array_diff_assoc | 53 | 0.02 |
309 | base_convert | 52 | 0.02 |
310 | imagesavealpha | 52 | 0.02 |
311 | setcookie | 51 | 0.02 |
312 | imagecopyresampled | 51 | 0.02 |
313 | fprintf | 50 | 0.02 |
314 | substr_compare | 50 | 0.02 |
315 | get_resource_type | 50 | 0.02 |
316 | fsockopen | 50 | 0.02 |
317 | xml_parser_create | 50 | 0.02 |
318 | ob_get_level | 49 | 0.02 |
319 | octdec | 48 | 0.02 |
320 | dir | 48 | 0.02 |
321 | mcrypt_generic_init | 48 | 0.02 |
322 | str_ireplace | 47 | 0.02 |
323 | date_format | 47 | 0.02 |
324 | curl_error | 47 | 0.02 |
325 | session_name | 46 | 0.01 |
326 | mb_strpos | 46 | 0.01 |
327 | php_uname | 46 | 0.01 |
328 | xmlrpc_server_register_method | 46 | 0.01 |
329 | curl_close | 45 | 0.01 |
330 | getmypid | 45 | 0.01 |
331 | set_time_limit | 44 | 0.01 |
332 | wordwrap | 44 | 0.01 |
333 | imagecolorallocatealpha | 44 | 0.01 |
334 | error_log | 44 | 0.01 |
335 | getdate | 43 | 0.01 |
336 | php_sapi_name | 43 | 0.01 |
337 | getSession | 43 | 0.01 |
338 | register_shutdown_function | 43 | 0.01 |
339 | mb_detect_encoding | 42 | 0.01 |
340 | ip2long | 42 | 0.01 |
341 | shell_exec | 42 | 0.01 |
342 | mysql_query | 42 | 0.01 |
343 | array_walk_recursive | 41 | 0.01 |
344 | gzinflate | 41 | 0.01 |
345 | 41 | 0.01 | |
346 | decbin | 40 | 0.01 |
347 | date_default_timezone_set | 40 | 0.01 |
348 | fileperms | 39 | 0.01 |
349 | md5_file | 39 | 0.01 |
350 | hash_equals | 38 | 0.01 |
351 | uksort | 38 | 0.01 |
352 | is_link | 38 | 0.01 |
353 | spl_autoload_unregister | 38 | 0.01 |
354 | putenv | 38 | 0.01 |
355 | str_getcsv | 38 | 0.01 |
356 | error_get_last | 37 | 0.01 |
357 | iconv_strlen | 37 | 0.01 |
358 | curl_errno | 37 | 0.01 |
359 | stripcslashes | 37 | 0.01 |
360 | strnatcasecmp | 37 | 0.01 |
361 | mime_content_type | 36 | 0.01 |
362 | bindec | 36 | 0.01 |
363 | settype | 36 | 0.01 |
364 | srand | 36 | 0.01 |
365 | xml_parser_set_option | 35 | 0.01 |
366 | stream_context_create | 35 | 0.01 |
367 | date_create | 34 | 0.01 |
368 | get_called_class | 34 | 0.01 |
369 | session_write_close | 33 | 0.01 |
370 | move_uploaded_file | 33 | 0.01 |
371 | create_function | 32 | 0.01 |
372 | xml_get_error_code | 32 | 0.01 |
373 | link | 32 | 0.01 |
374 | socket_last_error | 32 | 0.01 |
375 | mcrypt_generic | 31 | 0.01 |
376 | array_multisort | 30 | 0.01 |
377 | oci_error | 29 | 0.01 |
378 | gzcompress | 29 | 0.01 |
379 | natcasesort | 29 | 0.01 |
380 | sqrt | 28 | 0.01 |
381 | session_start | 28 | 0.01 |
382 | json_last_error_msg | 28 | 0.01 |
383 | get_magic_quotes_gpc | 28 | 0.01 |
384 | fmod | 28 | 0.01 |
385 | imagepng | 27 | 0.01 |
386 | inet_pton | 27 | 0.01 |
387 | stream_resolve_include_path | 27 | 0.01 |
388 | proc_open | 27 | 0.01 |
389 | xml_parser_free | 26 | 0.01 |
390 | is_uploaded_file | 26 | 0.01 |
391 | arsort | 26 | 0.01 |
392 | socket_strerror | 26 | 0.01 |
393 | openssl_encrypt | 26 | 0.01 |
394 | readfile | 26 | 0.01 |
395 | imagecopy | 26 | 0.01 |
396 | expression | 25 | 0.01 |
397 | imagecolortransparent | 25 | 0.01 |
398 | stream_get_wrappers | 25 | 0.01 |
399 | mt_srand | 25 | 0.01 |
400 | ldap_search | 25 | 0.01 |
401 | openssl_random_pseudo_bytes | 25 | 0.01 |
402 | ldap_get_entries | 25 | 0.01 |
403 | mysql_real_escape_string | 25 | 0.01 |
404 | sha1_file | 25 | 0.01 |
405 | apcu_fetch | 24 | 0.01 |
406 | fstat | 24 | 0.01 |
407 | strncasecmp | 23 | 0.01 |
408 | array_rand | 23 | 0.01 |
409 | highlight_string | 23 | 0.01 |
410 | stream_set_timeout | 23 | 0.01 |
411 | class_alias | 23 | 0.01 |
412 | gzuncompress | 23 | 0.01 |
413 | mysql_error | 23 | 0.01 |
414 | fputcsv | 23 | 0.01 |
415 | is_writeable | 23 | 0.01 |
416 | memory_get_peak_usage | 22 | 0.01 |
417 | xml_error_string | 22 | 0.01 |
418 | gettext | 22 | 0.01 |
419 | split | 22 | 0.01 |
420 | set_exception_handler | 22 | 0.01 |
421 | escapeshellcmd | 22 | 0.01 |
422 | spl_autoload_functions | 21 | 0.01 |
423 | Locale::getDefault | 21 | 0.01 |
424 | xml_set_element_handler | 21 | 0.01 |
425 | strpbrk | 21 | 0.01 |
426 | stream_select | 21 | 0.01 |
427 | ctype_alpha | 21 | 0.01 |
428 | get_html_translation_table | 21 | 0.01 |
429 | ob_get_length | 20 | 0.01 |
430 | sin | 20 | 0.01 |
431 | fgetcsv | 20 | 0.01 |
432 | imagejpeg | 20 | 0.01 |
433 | decoct | 20 | 0.01 |
434 | imagefill | 20 | 0.01 |
435 | imagecreate | 20 | 0.01 |
436 | pg_escape_string | 20 | 0.01 |
437 | ignore_user_abort | 19 | 0.01 |
438 | mcrypt_create_iv | 19 | 0.01 |
439 | is_executable | 19 | 0.01 |
440 | gzdeflate | 19 | 0.01 |
441 | session_status | 19 | 0.01 |
442 | levenshtein | 19 | 0.01 |
443 | xml_get_current_line_number | 19 | 0.01 |
444 | imagecolorsforindex | 19 | 0.01 |
445 | gmp_init | 19 | 0.01 |
446 | get_magic_quotes_runtime | 19 | 0.01 |
447 | iterator_count | 19 | 0.01 |
448 | checkdate | 19 | 0.01 |
449 | timezone_identifiers_list | 19 | 0.01 |
450 | get_defined_constants | 19 | 0.01 |
451 | sqlsrv_errors | 19 | 0.01 |
452 | mb_convert_case | 19 | 0.01 |
453 | xml_set_character_data_handler | 19 | 0.01 |
454 | ftruncate | 19 | 0.01 |
455 | imagecreatefrompng | 18 | 0.01 |
456 | timezone_open | 18 | 0.01 |
457 | session_regenerate_id | 18 | 0.01 |
458 | iconv_substr | 18 | 0.01 |
459 | popen | 18 | 0.01 |
460 | apc_store | 18 | 0.01 |
461 | gethostname | 18 | 0.01 |
462 | curl_setopt_array | 18 | 0.01 |
463 | proc_close | 18 | 0.01 |
464 | strripos | 18 | 0.01 |
465 | dl | 18 | 0.01 |
466 | imagerotate | 18 | 0.01 |
467 | mb_check_encoding | 18 | 0.01 |
468 | mcrypt_module_open | 18 | 0.01 |
469 | date_parse | 17 | 0.01 |
470 | fileowner | 17 | 0.01 |
471 | gmstrftime | 17 | 0.01 |
472 | mb_strrpos | 17 | 0.01 |
473 | mb_strwidth | 17 | 0.01 |
474 | libxml_clear_errors | 17 | 0.01 |
475 | restore_exception_handler | 17 | 0.01 |
476 | mt_getrandmax | 17 | 0.01 |
477 | ereg | 17 | 0.01 |
478 | mhash | 17 | 0.01 |
479 | fgetc | 17 | 0.01 |
480 | grapheme_strlen | 17 | 0.01 |
481 | posix_getpwuid | 17 | 0.01 |
482 | bcmul | 17 | 0.01 |
483 | apcu_store | 16 | 0.01 |
484 | dbx_error | 16 | 0.01 |
485 | set_magic_quotes_runtime | 16 | 0.01 |
486 | fflush | 16 | 0.01 |
487 | array_count_values | 16 | 0.01 |
488 | openssl_error_string | 16 | 0.01 |
489 | gethostbyname | 16 | 0.01 |
490 | natsort | 16 | 0.01 |
491 | ldap_error | 16 | 0.01 |
492 | symlink | 16 | 0.01 |
493 | apcu_delete | 16 | 0.01 |
494 | stream_socket_client | 15 | – |
495 | get_declared_classes | 15 | – |
496 | apc_fetch | 15 | – |
497 | passthru | 15 | – |
498 | ob_clean | 15 | – |
499 | rsort | 15 | – |
500 | mb_stripos | 15 | – |
Be First to Comment