Ad space (banner)
๐Ÿ˜PHP Lessons
Lesson 13 / 68

Using the Standard Library

In this lesson you will learn about the handy built-in functions in PHP's standard library so you can work faster. This is for anyone searching for "PHP built-in functions list".

PHP has a great many built-in functions for handling strings and numbers. strtoupper(), str_pad(), and count() are among the most used. The library is rich, and knowing what exists dramatically changes how much you have to implement yourself.

The sample code converts to upper case with strtoupper("hello"), pads with zeros using str_pad("7", 3, "0", STR_PAD_LEFT), and reads the number of elements with count([1, 2, 3]). Notice how each single short line does what would otherwise take several.

A common stumbling block for beginners is not realising a function for the job already exists and writing it from scratch. Getting into the habit of checking the official PHP manual for a similar built-in before you write anything improves both the quality and the speed of your code.

Having a working knowledge of the string and collection functions makes you noticeably faster. Real PHP development strongly favours reaching for the standard library over reinventing the wheel.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run PHP directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)