3 Lesser Known, Useful PHP Features

Even if PHP is responsible for powering four out of five websites, it has recently attracted a large amount of criticism for being badly designed.

Yet despite having a few inconsistencies, PHP is definitely improving and tends to be one of the easiest languages to learn.

Here are 3 lesser-known but useful PHP features that you should know about:

1: Password hashing

For several years, using one-way hashing functions, like sha1() and md5(), for encypting passwords was considered to be enough. But while they are fast, they can be vulnerable to brute force attacks. Now, the password hashing API in PHP 5.5 offers a strong solution. Best part: it is simple to use. You use password_hash() to encrypt the password.

Myphpnet2: Standard PHP Library (SPL)

SPL has been around since 2004 and remains PHP’s best-kept secret. While it is known as a library, you don’t require any external files. While known for being a core part of PHP 5, one of its main features include a set of iterators that can be chained so as to create specialized loops and that will filter values with very little code. Also, it supports data structures such as queues and heaps too.

3: Composer

Composer is a dependency manager for PHP that will download and install all files necessary for a project. While it isn’t an official replacement for PEAR, a number of leading packages such as Symfony, PHUnit and SwiftMailer have opted for Composer over PEAR. The problem with PEAR is that if a package stagnated, it wouldn’t be updated. Apart from this, installing Composer is easy too.