Setting up a Linux-based Website, Part 3: The power and the pitfalls of using PHP for Web programming
I have a confession to make: I am an undisciplined programmer at heart. Unless there is some external motivation to do otherwise, I tend to jump in and start coding a project with no formal plans. This approach usually leads to code that is difficult to extend or maintain, because one only discovers the true requirements of a project by bumping into the limitations of what has already been coded. The result is a continual state of rewrites.
This makes me somewhat of a hypocrite, because I quickly get annoyed with others who do the same -- most recently with PHP-Nuke. I've been modifying PHP-Nuke 4.4.1a for use as the publishing system for VarLinux.org and Petreley.org, which is a site I'm doing in my off-hours. (See Resources for more information on the Websites mentioned in this article.) PHP-Nuke is a Weblog publishing system, written in PHP, with MySQL as the database back end.
To be fair, PHP-Nuke's programmers may not have deliberately taken a disorganized approach; they may have simply fallen into some common PHP traps. Although it is entirely possible to build a modular Website with PHP, the language tends to discourage modularity because PHP code integrates right into HTML.
That is why PHP is simultaneously irresistible and prone to disorganization. It is irresistible because with PHP, you can crank out MySQL data and turn it into a page of information more easily than with just about any other Web-programming system. It is prone to disorganization because the HTML opening formatting tags that you create inside a PHP function are often completed by other PHP functions. That means that every time you change the opening formatting tags, you have to find every occurrence where the closing tags must match. The format tags that get you into trouble most often are the table, row, and data tags. If you don't handle those tags properly, many of your page elements will be scattered into the wrong places.
One way to avoid this is to create a function for every combination of opening and closing tags. Then you have to maintain only those functions, not the formatting within other functions. In the current version of PHP-Nuke, you can see that the coders tried to implement this in some places, but it was probably too late to revamp the whole project without starting over. That is what they ultimately did, though -- PHP-Nuke 5.0 is on its way, and it is built almost from scratch.
The worst news is that I don't know of any HTML syntax checkers that can process PHP pages. And I wouldn't expect to find any, because it would be extremely difficult for
Symantec Backup Exec 12 and Backup Exec System Recovery 8 deliver industry leading Windows data protection and system recovery. Download this whitepaper to find out the top reasons to upgrade and how to get continuous data protection and complete system recovery.
Data and system loss — from a hard drive failure, malicious attack, natural disaster, or simple human error — can happen anytime. Don’t leave your business vulnerable. Make sure you have a secure recovery strategy in place. Symantec's latest backup and system recovery technology can efficiently restore critical applications, individual emails and documents and even restore your entire system in minutes in the event of a loss.
Businesses face a growing challenge to ensure that the IT environment is properly protected. Backup Exec 12 integrates with other applications in the Symantec family of products, to complement your current data protection strategy, keep your data securely backed up and make it recoverable when you need it most.







