PHP5 has brought so much new features but because of its big syntax changes, a big percentage of the PHP developing base has not made the change. Here are the top 10 new features that could change your mind.
- Better Error Handling with Exceptions
I am sure every PHP developer had been staring at the famous white screen with a â€œSyntax errorâ€ clueless at where the error is really at. With PHP5, you can actually handle PHP errors and do whatever you want with them, but that is not all. They have also included exceptions which I am sure most C++ or Java developers use. The good part is that instead of simply failing on with close no errors to you, you could put a few checks before and information you could need such as maybe a
print_r()on an array. I have written an article about this: https://vexxhost.com/blog/?p=21
- Completely Rewritten MySQL Extension
The MySQL databases are the PHP’s partner in crime. Many developers use this database system in their website’s because it is one of the easiest, free, open-source database software. However, its performance combined with PHP4 was close to poor. Introduced with PHP5 is a newer, rewritten, optimized MySQL extension which was also compatible with MySQL 5.0. It has also introduced other functions such as: Prepared statements, SSL connections, Multi-query functions.
- Way More Useful Functions
I have a few favorite PHP5 functions which speed up time while coding & enhances the website’s performance. One of my favourites is the
__autoload()function â€“ What it does if a class that was created and did not exist. It provides you with the class name. This is useful because you do not need to manage what includes you need for X and Y file and reduces the load for those who simply include all the classes in for every single PHP file. Also, another favorite is
file_put_contents()which reduces the 6 lines of code to add something to one.
- Finally! SQLite Database Support!
I am sure a lot of developers will be happy about this one. While MySQL is very popular among most PHP developers, SQLite is much different than it. It actually uses normal files and reads them. It does not need a daemon (or called server) to run in order to execute any queries on it. It makes a better smaller database for these low traffic sites.
- The Best OOP Support Period
PHP programmers have spent an awful of long time trying to create hacks so in order that PHP can make a better OO programming language. Finally, they are rewarded with OO support that either PHP3 or PHP4 can match. It has anything you usually see in most of the other established coding languages. From constructors, destructors, public, protected, private properties & methods, interfaces, abstract classes, class type hints, static properties and methods, final properties, methods and the whole suite of magical methods.
That is the top 5 for us. I hope you think that PHP5 deserves a try! (and we offer it with our hosting plans too!)