Innovate faster and cut risk with PHP experts from Zend Services.
Beginning to advanced PHP classes to learn and earn global certification.
Help me choose >
Submit support requests and browse self-service resources.
In this blog, we give an introduction to PHP extensions for beginning PHP developers. Then we give more in-depth definitions for developers familiar with PHP extensions.
A PHP extension is a specially formed library or plug-in that provides a function that can be used by many applications.
By using extensions, you can avoid having to recreate the same code for numerous applications. To use an extension, you simply connect it to your application’s PHP binary.
You can make use of a publicly available extension or create your own to:
PHP extensions are usually written in C and then compiled to native machine code. However, PHP 7.4 introduced Foreign Function Interface (PHP FFI), which enables PHP developers to write extensions and bindings to C libraries in pure PHP.
The term .php file extension refers to the name of a file with a PHP script or source code that has a ".PHP" extension at the end of it. It's similar to a Word file with a .doc file extension.
PHP extensions are not the same thing as a .php file extension or PHP class extension (inherited classes). A PHP extension is a specially formed library or plugin. But a .PHP file extension is the name of a file. And a PHP class extension refers to a class that extends another.
In other words, files that have a .php file extension are not the same thing as an extension a PHP developer uses in code to extend functionality.
If you have developed any code in PHP, you have already used extensions. Almost all the functions and classes provided by PHP come from different extensions. One of the simplest examples is the function strlen() implemented in “standard” extension. Another example is “mysqli_connect,” which is implemented in the “mysqli” extension.
If your application needs some new functionality that is potentially useful for other applications, you should consider using a reusable library. You can add it by:
If you are lucky, you will find an extension that already provides the feature. There is a rich set of extensions maintained and distributed with PHP. For example, PHP 7.4 provides about 70 different extensions. Some of them are always compiled and linked directly into the PHP binary, like “standard.” These extensions are available out of the box.
Other extensions are optional. Oftentimes, these are distributed as dynamic plug-ins that should be loaded though the php.ini extension directive — for example, extension=mysqli.so.
Despite the extensions that come with the PHP core, you can find a lot of third-party extensions on the Internet. One of the biggest repositories — https://pecl.php.net/packages.php — contains almost 400 extensions. Not all of them are stable, portable among different PHP versions, and/or well supported. If you see an extension that could be useful, you need to try it to determine if it meets your requirements.
Because existing extensions don’t cover all the application domains, from time to time, you will need to develop a new extension. Companies that do business with PHP often develop extensions with very specific functionality. They also use extensions to re-implement mission-critical parts of code in C, to achieve better performance.
Learn more about PHP extensions in our technical guide, including:
PHP Extensions Technical Guide
PHP extensions are just one aspect of PHP development. There's a lot else to consider, like debugging, security, deployment, performance, and integrations. PHP training can help you learn more.
But using the right PHP development tools will help you development better applications. One of the best tools to use is Zend Server.
Zend Server is a PHP application server. You can use Zend Server to:
See for yourself how Zend Server will help you. Get started with a free 30-day trial.
Try Zend Server
Blog: Running SOAP WS-Security Load Tests in JMeter
Principal Engineer, Zend by Perforce
Dmitry started using PHP in 2000 and very soon turned into an internal PHP developer. He lead the Turck MMCache project for PHP-4 (which is similar to modern opcache). In 2003, Dmitry joined Zend and helped develop most of the core PHP subsystems during PHP-5's life. Later, Dmitry lead the PHPNG project, which brought the speed of PHP-7 to a new level and helped contribute to the release's success. Currently, Dmitry works at Zend by Perforce as a Principal Engineer and leads the development of the JIT compiler for PHP. He lives and works from his home in St. Petersburg, Russia.