Extending PHP

The base of the PHP language is simple, having just enough to set and retrieve variables, work with loops, and check whether a statement is true or not. The real power behind PHP comes with its extensions —add-ons to the base language that give it more flexibility. PHP has hundreds of extensions, which can be broken down into five types: core, bundled, PECL, third party, and DIY.

  • Core extensions are extensions bundled with PHP itself and enabled by default. For all intents and purposes they are part of the base language, because, unless you explicitly disable them (few people do, and sometimes you cannot), they are available inside PHP. For example, the mechanism to handle reading and saving files in PHP is handled by an extension automatically compiled into PHP.

  • Bundled extensions are extensions included with PHP but not enabled by default. They are commonly used, which is why they are included, but they are not available unless you specifically enable them. For example, the mechanism to handle graphics creation and editing is handled by an extension that is bundled with PHP but not enabled by default in php.ini.

  • PECL (pronounced "pickle") stands for "PHP Extension Code Library" and was created as a place where rarely used or dormant extensions could be moved if they were no longer considered relevant to the core PHP distribution. PECL has grown since its founding, and is now the home of many interesting and experimental extensions that are not yet important enough ...

Get PHP in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.