
PHP5 was a significant update to the PHP language, released in 2004. It brought many improvements and new features.
One of the key changes in PHP5 was the introduction of object-oriented programming, which allowed for more organized and scalable code. This was a major departure from the procedural programming style of earlier PHP versions.
PHP5 also improved performance, with significant speed boosts and memory reductions. According to benchmarks, PHP5 was up to 50% faster than PHP4.
The new version also introduced a number of new features, including support for MySQLi and PDO, which made it easier to interact with databases.
New Features
One of the most exciting aspects of PHP5 is its new features, which make coding easier and more efficient.
The built-in support for SQLite databases is a game-changer for web developers. It allows for fast and easy data storage without the need for external libraries.
Error handling has been improved with the introduction of the Exception class, making it easier to catch and handle errors in a more robust way.
The new function, array_merge, makes it possible to merge two or more arrays into one, which can be a huge time-saver in certain situations.
What's New in PHP 5

PHP 5 was released 4 years after the introduction of PHP 4, aimed to bring a brand new functionality to the PHP language.
The PHP team focused on what was missing or not well supported in the older versions. They aimed to improve the language significantly.
PHP 5 is focused on three major areas: Object-Oriented programming, XML and MySQL support. This new focus brought a lot of changes to the language.
Object-Oriented programming was one of the key areas of improvement in PHP 5. This allowed developers to write more modular and reusable code.
XML support was another area where PHP 5 excelled. The new version made it easier to work with XML data.
MySQL support was also a major area of improvement in PHP 5. The new version made it easier to interact with MySQL databases.
Breaking Changes
PHP 5 is a more reliable choice than PHP 4, which is outdated and no longer well-tested for WordPress. PHP 4 is officially end of life since August 2008, meaning no security patches have been released in over a year.

Some WordPress plugins and themes are only compatible with PHP 5 and its improved features, making them incompatible with PHP 4 or older PHP 5 versions. Check with the authors for specific requirements.
Older themes and plugins may have PHP code that won't work with every PHP 5 version, so it's essential to check with the authors for the latest requirements. If your plugin hasn't been updated in years, look for updated versions or consider changing to an alternative option.
Switching from PHP 4 to PHP 5.2 can cause issues with the "open_basedir restriction", resulting in gibberish appearing above the WordPress blog header. However, most hosts, including Blue Host, support PHP 5 by default.
Here's a list of some things to keep in mind when switching from PHP 4 to PHP 5:
- Check with the authors of your themes and plugins for specific requirements.
- Look for updated versions of your plugins if they haven't been updated in years.
- Consider changing to an alternative option if your plugins are no longer supported.
- Be aware of potential issues with the "open_basedir restriction" when switching to PHP 5.2.
Object-Oriented Programming
Object-Oriented programming in PHP 5 is a game-changer. It offers a completely reworked object model.
Constructors and destructors are now part of the PHP 5 object model, allowing you to initialize and clean up objects as needed.
Programmers can also pass objects by reference, giving you more flexibility when working with complex data structures.
Public, protected, and private properties and methods are now available, enabling you to control access to your object's inner workings.
Here are some of the key features of PHP 5's object model:
- Constructors
- Destructors
- Public, protected, and private properties and methods
- Interfaces
- Abstract classes
- Class type hints
- Static properties and methods
- Final properties and methods
- Magical methods
In addition to these features, PHP 5 also includes interfaces and abstract classes, which allow you to define contracts and blueprints for your objects.
Exception Handling
Exception handling is now present in the PHP core, allowing for a separation of the programming logic and the error handling.
Exceptions were completely missing in PHP 4, but are now a standard feature in PHP 5, just like in other Object-Oriented languages such as Python and Java.
The coder can now place exceptions in adjoining blocs for easier referencing, making error handling much more manageable.
This separation of concerns makes coding easier and more efficient, allowing developers to focus on writing clean and logical code.
Database Extensions
PHP 5's database extensions have seen some significant improvements. The reworked MySQL extension now supports the newest version of MySQL, labeled MySQLi, which stands for MySQL improved.
This new extension offers a range of features, including prepared statements, bound input and output parameters, and SSL connections. With prepared statements, you can execute the same SQL statement multiple times with different parameters without having to rewrite the statement each time.
The MySQLi extension also includes multi-query functions, which allow you to execute multiple queries at once. This can be a big time-saver, especially when working with complex databases.
Here are some key features of the MySQLi extension:
- Prepared statements
- Bound input and output parameters
- SSL connections
- Multi-query functions
- MySQL can now use PHP's new OO model
Reworked MySQL Extension
The reworked MySQL extension in PHP 5 is a significant improvement over its predecessor. It provides support for the newest version of MySQL, now labeled MySQLi, which stands for MySQL improved.
One of the key features of the new extension is prepared statements. This allows for better security and performance. Prepared statements enable you to separate the SQL code from the data, making it harder for hackers to inject malicious code.
The new extension also offers bound input and output parameters. This feature allows you to specify the type of data that will be bound to a parameter, making it easier to work with different data types. Bound input and output parameters help prevent SQL injection attacks.
Another feature of the new extension is SSL connections. This allows you to establish a secure connection between your PHP script and the MySQL database. SSL connections are essential for protecting sensitive data.
The new extension also includes multi-query functions. This allows you to execute multiple queries at once, making it easier to perform complex database operations. Multi-query functions can improve performance by reducing the number of round trips to the database.
Here are the key features of the reworked MySQL extension:
- Prepared statements
- Bound input and output parameters
- SSL connections
- Multi-query functions
Reworked Xml Extension
The reworked XML extension in PHP5 is a game-changer. It's now possible to work with multiple XML tools together seamlessly.
One of the key benefits of this new extension is that it's included in a single library: libxml2. This makes it easier to manage and maintain your code.

The new XML extension provides efficient data processing, which can be a huge time-saver for developers. I've seen this firsthand in my own projects, where the ability to quickly parse and manipulate XML data has been a huge productivity boost.
Here are some of the key features of the new XML extension:
- Can work together as a whole.
- Fully comply with W3 specifications.
- Provide efficient data processing.
- Can provide you with the exact XML tool for the task at hand.
The SimpleXML extension is also a part of this new XML extension, allowing you to easily handle data in XML documents by treating it as an array and looping through it. This makes it easy to work with complex XML data and extract the information you need.
Hosting and Compatibility
PHP 5 is supported by most web hosting plans, including those offered by NTC Hosting, which provides a convenient tool to switch between PHP 4 and PHP 5.
Some web hosts, like 1&1 Germany, require specific code additions to the .htaccess file to parse all PHP files in PHP 5. Similarly, OVH and cPanel-based web hosting services also require specific configuration changes to switch to PHP 5.
On a similar theme: Php Web Page Design Templates
Many web hosts, including Blue Host, HostMonster, and GoDaddy, support PHP 5 by default, making it easy to switch from PHP 4. However, it's essential to check with your web host for specific instructions and requirements for switching to PHP 5.
Here are some examples of how to switch to PHP 5 on various hosts:
Keep in mind that some WordPress plugins and themes may not be compatible with PHP 5, so it's crucial to check with the authors for specific requirements.
Will it break WordPress themes or plugins?
WordPress runs better on PHP 5 than on PHP 4, which is outdated and no longer well-tested.
PHP 4 is officially end of life since August 2008, meaning no security patches have been released in over a year.
Some plugins and themes are only compatible with PHP 5 and its improved features.
Older themes and plugins may have PHP code that won't work with every PHP 5 version, so check with the authors for specific requirements.

If you're using non-WordPress-specific code, such as JavaScript or custom PHP scripts, check with the original source for updated versions.
PHP 5 is mostly backwards compatible, so you shouldn't run into problems normally.
However, switching from PHP 4 to PHP 5.2 can cause issues like the "open_basedir restriction" error, which may display gibberish above the WordPress blog header.
Here are some hosting providers that support PHP 5 by default:
- Blue Host (Confirmed) - Supports PHP 5 by default.
Web Hosting Switch Examples
If you're looking to switch to PHP5 on your web hosting, don't worry, it's easier than you think. You can add the following lines of code to your root directory's .htaccess file to parse all php files in php5: OVH requires this line of code, and 1&1 Germany also needs it for their WebHosting 5.0 package.
To make the switch on other web hosting services, you'll need to check their control panels. For example, GoDaddy requires you to select "PHP 5.x" as the version in their Hosting Control Center, while Gradwell asks you to change the zone file to Default hosting on php 5 cluster.
If this caught your attention, see: Php Web Dev
HostMonster supports PHP 5.2, 5.2fastCGI, 5.3, 5.4 & 5.4fastCGI by default, so you don't need to do anything extra. But if you're using cPanel, you'll need to select PHP 5 from the dropdown box on the PHP configuration page and click the "Update" button.
Here's a quick rundown of the steps you'll need to take for each web hosting service:
NTC Hosting
NTC Hosting offers web hosting plans that support PHP5, giving you the flexibility to choose between PHP4 and PHP5 through their Web Hosting Control Panel.
Their Web Hosting Control Panel comes equipped with a convenient tool that allows you to make this choice and provides you with the necessary tools to create your unique website.
NTC Hosting has prepared a detailed comparison between the available PHP versions to help you choose the right one for your needs.
Notes About Ini
When you're working with PHP, you need to know a few things about the ini file. The preconfigured PHP 5 package on Windows uses the php.ini file found inside its installation directory.
You can change the location of the php.ini file by setting the PHPRC environment variable. This is useful if you need to store your php.ini file in a different directory, like C:\mysettings.
The default php.ini file has some extensions enabled by default, including ImageMagick, mbstring, cURL, GD2, IMAP, GetText, LDAP, OpenSSL, PDO, ODBC, SQLite, MySQL, and MySQLi.
The MySQLi extension is especially important if you're using MySQL 4.1 or higher, as it can help prevent error messages like MySQL error #1251.
To enable other extensions, you'll need to edit the php.ini file. This can be done by opening the file with a text editor like Notepad and uncommenting the line that contains the extension name.
For example, if you want to enable the PHP PDF extension, you'll need to remove the leading colon character from the line that says "extension=php_pdf.dll".
Setup and Installation
To set up PHP 5, you'll need to download and install the preconfigured package for your operating system. If you're using Windows Vista, 7, 8, 8.1, 10, 2008, 2012, 2016 or later, download the preconfigured PHP 5.6.40 package for Windows.
The package includes a range of built-in extensions, such as bcmath, calendar, and zlib, as well as support for popular scripts. It also includes extensions for mbstring, cURL, GD2, and MySQL, but these are not enabled by default.
To install the package, simply extract the contents to a directory of your choice, such as C:\Program Files\PHP5.
Here's a quick rundown of the extensions included in the package:
- bcmath
- calendar
- zlib
- mbstring
- cURL
- GD2
- MySQL
With the package installed, you're ready to declare the interpreter and add PHP 5 support to your web server.
Setup
To set up PHP on your Windows system, you'll first need to download the preconfigured package from the official website. If you're using Windows Vista, 7, 8, 8.1, 10, 2008, 2012, 2016 or later, download the preconfigured PHP 5.6.40 package for Windows.
The preconfigured package contains the core PHP binaries and all its official extensions, which run on both 32 and 64-bit editions of Windows. It also includes built-in extensions like bcmath, calendar, and zlib, as well as support for popular extensions like cURL, GD2, and MySQLi.

You can install the package contents in a directory of your choice, such as C:\Program Files\PHP5. To do this, simply extract the downloaded zip file to the desired directory.
Here's a list of the built-in extensions included in the preconfigured package:
- bcmath
- calendar
- zlib
- cURL
- GD2
- MySQLi
- mbstring
- GetText
- LDAP
- OpenSSL
- PDO
- ODBC
- SQLite
- MySQL
If you need to activate additional extensions, you can do so by editing the php.ini file.
Declare the Interpreter
To declare the interpreter for PHP 5 support in Abyss Web Server, you'll need to access the console's Hosts table. If you're using an old version of the server, you'll be prompted to upgrade to the latest version, which is free and preserves your current configuration.
First, navigate to the Hosts table and press Configure in the row corresponding to the host you want to add PHP 5 support to.
Next, select Scripting Parameters and check the box next to Enable Scripts Execution.
You'll then need to add a new interpreter by pressing Add in the Interpreters table.

Here are the specific interface settings you'll need to make, depending on your operating system:
If you don't see an Interface field, you can ignore this step and proceed with the next instructions.
In the Interpreter field, press Browse and locate the php-cgi.exe file in the directory where you've installed PHP 5.
Set the Type to Standard, as PHP Style is no longer recommended for use.
Featured Images: pexels.com
