PHP5: Extensions

Posted on March 10, 2011

I thought I’d finish up by mentioning some of the extensions built into PHP5. There are many other extensions that can be added from a 3rd-party library or PECL extension.

A lot of these existed in PHP4 too, but you may not be familiar with them, and obviously they’ve been updated since PHP4 as well.

  • BCMath — The “Binary Calculator” extension lets you perform basic arithmetic on numbers of any size and precision (given in string format).
  • calendar — Provides utility functions to convert dates between different calendar formats: Julian, Gregorian, Jewish, and French Republican. Also some handy functions for getting the date for Easter in a given year.
  • ctype — A bunch of functions to check whether a character/string falls into a certain class (e.g., alphanumeric, printable, etc.).
  • curl — This extension uses the famous curl library to connect to and communicate with servers using a variety of protocols. No more reliance on PEAR libraries!
  • DBA — A database abstraction layer for Berkeley DB and similar file-based databases.
  • DOM — Lets you traverse and modify the document object model from XML.
  • Exif — Lets you read the metadata in photos taken on digital cameras
  • FileInfo — Functions to guess the type and MIME encoding of files.
  • Filter — Sanitizes and validates data.
  • FTP — An extension for communicating with servers over the FTP protocol. We actually got MCG to enable this extension on the current server.
  • gettext — The gettext library is for translation capability. You’ve probably seen all those .mo and .po files — those are gettext translations.
  • GMP — This extension lets you work with arbitrary-length integers, similar to BCMath. Like BCMath, it accepts strings, but you can also create GMP objects to represent the numbers. It also supports more operations than BCMath.
  • Hash — Support for more hash algorithms than just md5() and sha1(). Also has functions to compute the hash of a file, and for computing HMACs.
  • iconv — Convert strings to different character sets.
  • IMAP — Communicate with servers using the IMAP, POP3, and NNTP protocols.
  • JSON — Encode and decode strings in Javascript Object Notation format.
  • LDAP — Communicate with servers using the LDAP protocol.
  • mbstring — Support for multibyte character sets. It might be the preferred method for converting character encoding, depending on your needs. (This extension is also already available on our server.)
  • mcrypt — Two-way encryption routines! (This extension is already available on our server.)
  • pspell — Check the spelling of words and get suggestions. (This extension is already available on our server.)
  • SimpleXML — Lets you convert an XML document into an object that you can easily traverse using properties and arrays. Less complicated than the DOM extension, but doesn’t have all the functionality of that extension.
  • SOAP — Functions to act as a SOAP server or client, including WSDL support.
  • SPL — The Standard PHP Library deserves an article all for itself.
  • SQLite — Support for reading and writing to SQLite embedded databases.
  • SVN — This extension is still in development (“experimental”), but I thought I’d mention it since it could be useful.
  • Tidy — The main purpose of the Tidy library is to clean and fix up malformed HTML, but you can also use it to traverse HTML.
  • XSL — Lets you perform XSLT transformations on XML documents.
  • Zip — Lets you read and write files using Zip compression. There’s both a procedural interface and an OO interface.

Leave a Reply