PHP Coding Standards

Written by on November 22, 2008 in General - 5 Comments

There is a lot of articles on the Internet about: becoming better programmer, writting better and more readable code, where someone just makes a list of techniques or tips (as they call it) that will make you a better programmer. In fact these articles are usually far from providing you with valuable information and most of the time can be summarized with two words – coding statndards.

What are PHP coding standards?

I do not want to give here links to low quality content, so i will just use phrase “these articles”. So these articles (:)) usually provide you with coding standards, but not all coding standards are equal, there are good ones and there are bad ones. The best place to search for them should php manual but unfortunately it is not. I mean just look at it. Functions, even in the same category are written with underscore (eg. str_replace) or without it (eg. strlen) and as far as i am concerned there is no such chapter as php coding standards in the whole manual. So the answer to the question “What are PHP coding standards?” is: there are NONE.

Why coding standards are important?

One can think that if PHP developers did not came up with some coding guideline then maybe they are not so important? This cannot be any further from truth, because good coding guidelines:

  • handle all naming conventions and you never have to think how to name variable, function or a class
  • improves your development speed (mainly because of point one)
  • makes your code more readable for other developers as well as for you

Where to get coding standards?

You can write your own coding standards if you are working by yourself and do not use any framework, there is nothing wrong with that. However if you are planning to use one of the popular frameworks then it is good to use their coding standards, maybe it is a little strange but despite there is no coding guidelines for PHP there are coding standards for PHP frameworks.

Actually if you do a search on coding standards for any popular PHP FrameWork you will find them. Also even if you do not plan using any of the listed frameworks above it is good to select one of them and apply their coding guidelines in your projects. I think all of them are great examples because they are based on the experience of literally thousands of PHP programmers, why not to take advantage of that? More over i am sure this standards of PHP programming will somewhat help you in your web development, it is also useful to know how others are “doing it”.

About the Author

Greg Winiarski is a freelance PHP and JavaScript programmer. He specializes in web applications and WordPress development.

5 Comments on "PHP Coding Standards"

  1. Seo Explode March 8, 2009 at 8:26 pm ·

    I am new at this stuff (PHP coding).
    Your post can help me to understand everything
    that i need to know.

    thanks a lot for your tutorials.
    I’ll keep on coming back to learn
    more!

    Great site and informative!!!

  2. Johan August 10, 2009 at 7:58 pm ·

    Thanks for the links! :) Already got the first, but it helped me alot with the second 2.

    Now I can start making my new blog and structure the code nice at the same time! :)

  3. Rebbeca Abbed May 30, 2010 at 6:41 pm ·

    Howdy there,Awesome article dude! i am just Fed up with using RSS feeds and do you use twitter?so i can follow you there:D.
    PS:Have you thought about putting video to this web site to keep the readers more enjoyed?I think it works.Kind regards, Rebbeca Abbed

  4. Charleston Cruise March 30, 2011 at 7:40 am ·

    I am constantly looking for good information on this topic. It can be difficult to find sometimes. Thanks!. I will check back on your site from time to time for more information.

  5. Roy M J December 28, 2011 at 12:00 pm ·

    Ive been searching for such a guideline for long. Ive tried keeping the code as clean as possible. But i had no idea with how the coding standards are actually.. Going through certain frameworks surely helped a lot.. If fact this should be followed fro the very beginning of our career as a developer as we would surely fail to retract back to what we are accustomed in doing.. Great post..

Leave a Comment