
There are millions of lines of PHP code freely available to download from the Internet, but how can you tell if the script you are about to install is going to send your site into oblivion or code nirvana?
At the last count the popular resource site HotScripts.com listed over 6,800 PHP scripts with similar resource sites listing thousands more. No matter where you look on the Web you will find plenty of PHP code that you can download and install onto your web site covering just about everything you could ever need. The ease of developing with PHP has lead to the creation of this script gold mine, and while it can be a wonder to explore there are many factors you should take into consideration before going on a downloading frenzy.
Will the script you are about to install bring your server to a halt? Does it open up glaring security issues? Is there a mess of complex and poorly written code behind the sleek HTML exterior? In this article we get our pick axes ready, delve deep and bring back examples that serve one purpose: to show you what to look out for in other peoples code. By looking at good, bad and just downright ugly snippets of code you can gain a far better understanding of the overall quality of a PHP script.
Cutting Edge or Over the hill?
Looking at the version of PHP a script was developed for can often provide you with explanations for the way the author has tackled certain problems and give you a good idea of issues to look out for.
Having located and downloaded a script, one of the first things you can check are the dates on the files. PHP is a rapidly changing language and with version 5 just around the corner it pays to keep abreast of these updates, but has the author of the script you’ve just found? The leap from PHP4 to PHP5 will be significant, just as it was from PHP2 to 3 and PHP3 to 4, so how can you tell when your newly acquired script was written?
The truth of the matter is that unless the author specifically states in the documentation the version of PHP their script was developed for, you’ll have a hard time working it out. Start by reading any text files or code comments you can find, searching for that elusive version number. If that fails to turn anything up you can look at the dates of the files and compare them to the PHP release chart (Table 1). Obviously this isn’t a bullet-proof method, but it may prove useful in your investigations.
Open Table 1 in a new browser window