Saturday, August 28, 2010

PHP coding standards

While we create applications in any language, we tend to follow certain coding conventions. So does this apply to creating applications in PHP as well.

Here is a list of few coding standards that i follow:
1. Use camelCaps for Variable Names
2. Use lowercase for method / function names. For functions with multiple words, an underscore is used as a separator. For e.g. function get_display_text();
3. Use class constants instead of global constants wherever possible, by using the const modifier.
4. Use descriptive variable names in for loops as well.
For e.g. $count instead of $j
for($count=0;$count < 10;$count++){
your code here
}

and many more....

It would also be great if you could also pour in your thoughts on the coding conventions you follow while writing applications in php.

Creative Commons License

No comments:

Post a Comment