Zend PHP 7 Certification – Basics – Extensions

This post covers the Extensions section of the PHP Basics chapter when studying for the Zend PHP 7 Certification.

The most common way for PHP extensions to be loaded is through the php.ini configuration file.

Usually on UNIX based servers, there may be more than one php.ini files on a server. Therefore, to find out the configuration file that’s actually being used, you can use PHP’s phpinfo() function.

This function will show a Configuration File (php.ini) Path and Loaded Configuration File value, where you’ll be able to see the configuration file used.

Extensions are loaded into php.ini using the extension line.

// php.ini

On UNIX systems, extension libraries usually contain a .so extension.


On Windows systems, it is usually a .dll extension.


PHP will look for the extensions using a extension_dir directive, which is a directive set in php.ini. This declares the directory that the extensions are located in.

extension_dir = "/some/extensions/folder"

Depending on how PHP is being used on the web server will depend on if you need to restart any services after modifications made to php.ini.

  • If using PHP a module, then you have to restart the server process.
  • If using PHP as CGI backend, then you do not have to restart the server process.
  • If using PHP-FPM, you have to restart the FPM server process to prevent configuration inconsistencies.

Note that as well as viewing extensions using phpinfo(), you can also pass in an INFO_MODULES parameter:


There is also a get_loaded_extensions() function.


PECL is a repository for PHP Extensions, providing a directory of all known extensions and hosting facilities for downloading and development of PHP extensions.

The packaging and distribution system used by PECL is shared with its sister, PEAR.

Extensions include APC, Solr and Mcrypt.

Core Extensions

There are a set of php extensions that are part of the PHP core and cannot be left out of a PHP binary with compilation options. These include but not limited to:

  • Arrays
  • Classes/Objects
  • Date/Time
  • Mail
  • Sessions
  • Strings

Userland Rules

When choosing names for any code that creates symbols in the global namespace, it is important to take into account the following guidelines to prevent future versions of PHP conflicting with your code.

Function names in PHP use underscores between words, while class names use both the camelCase and PascalCase rules.

PHP reserves all symbols starting with __ as magical. It is recommended that you do not create symbols starting with __ in PHP unless you want to use existing magical functionality, such as __get() and __isset().

View the other sections:

Note: This article is based on PHP version 7.0.