PHP
  Home arrow PHP arrow PHP Application Development Part One
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

PHP Application Development Part One
By: David Fells
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 90
    2005-03-01

    Table of Contents:
  • PHP Application Development Part One
  • Directory structure
  • File naming conventions
  • Coding conventions
  • PHP coding conventions
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    PHP Application Development Part One


    (Page 1 of 6 )

    Settling for the "quick and dirty" solution often costs far more time than it saves. This is as true of PHP coding practices as anything else. In this first article in the series, you will learn practices that will save you time and headaches in the long run, and help you write better PHP code.

    When building applications in PHP, it is often far too simple to settle for the “quick and dirty” solution – poorly written, monolithic code that will never be used again and lacks any clear intent. Since PHP is typically used in small projects that could themselves be described as “quick and dirty,” developers will excuse their poor code by stating that they will not have to work on the code again and that they have no intention of ever reusing it. The fact remains, however, that as with any job worth doing, it should be done well.

    This paradigm holds true in this situation for a number of reasons. First, when you take the time to write good code, you will almost always find something reusable in any new code you write. Second, code will always require maintenance or changes. It may not be you, but it will be someone, someday – that is of course unless the code is so bad the poor fellow has to start from scratch. The intent of this article is to cover some of the most fundamental, low level rules of writing good PHP code.

    The first practice we will discuss covers directory structure and security along with filesystem naming conventions for PHP applications. After that, we will cover some coding conventions such as function and variable naming, indentation, and more. Lastly we will review basic coding considerations to provide flexibility, scalability, and efficiency. Before beginning, let it be understood that some of the conventions advocated in this article could be considered a matter of preference and are by no means the single correct solution, however they are time tested and have proven effective time and again in application development.

    More PHP Articles
    More By David Fells


       · I really like this article. It provides a lot of great information on good PHP...
       · I will respectfully disagree with your comments =) PHP is a remarkably fast...
       · Nice work! I always love to see articles relating to coding practices. Good luck on...
       · Perhaps that is where my true disagreement is. I for one think:"She has a...
       · I will be mentioning templates later in the series and discussing why you should...
       · Extreme example but compare the following two - find $chartype in each:"Not only...
       · All right, you've convinced me. Placing the variables outside of the string is...
       · 0verall, this was a great article for covering basic PHP coding conventions. The...
       · Thanks for the reply. I agree that using underscores is an acceptable convention,...
       · In your article you stated;------ <?php $obj = &new MyObject();...
       · Somehow I did forget to mention that was fixed in PHP 5 - could've sworn I had....
       · Right. Good article.I've noted a small mistake though:<quote>for ($i = 0;...
       · It was my understanding that unless an object contained lots of data, such as a huge...
       · ...I just wish I'd read it a year ago. It's comforting other people have to refer...
       · On a similar note, I used to think while() loops were more efficient than foreach()...
       · I did tests on this about a year ago and got some pretty dramatic results. I'm sure...
       · Thanks for pointing that out, I'll make sure it's fixed. I promise I know the right...
       · I think you meant "comma", not "colon", when you stated:the correct spelling...
       ·  $myNumber = 2; $myNumberSquared = Math::square($myNumber);[b] print...
       · Right!Thank god I don't right articles...
       · Yes, I like the underscore better for file names, because when you copy files...
       · Just my two cents:I've read somewhere that this:echo 'Welcome back ',...
       · I knew what he meant, the correction has already been made. Thanks =)
       · I agree with satane and the previous poster; _ is my prefered method. I come from a...
       · Your example, "did i name it myDb or myDB", implies a lack of agreed upon naming...
       · What methods do you use to benchmark your PHP applications? Thanks.Ben
       · Not true. Passing echo parameters is slower than concatenation. I've done timing...
       · You could do this in at least a few ways...Use a load generator to check the...
       · [quote]placing variables outside of strings increases readability[/quote]I think...
     

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT