Friday, July 16, 2010

Best Code Development Practices for PHP Developers-I

Providing some of the common PHP software development guidelines:

1 ) NAMING CONVENTIONS FOR FILES (REQUIRED):
All files including code, images, css,scripts, etc must be named in lowercase with multiple
words separated by underscore.Filenames must NOT contain any special characters.For example,
hello_world.php or hello.php are correct, but helloworld.php,helloWorld.php and HelloWorld.php are
not.
i) Include Files: The name of include files should be as below hello_world.inc.php
ii) Class Files: The names of Class files may be as below hello_world.class.php
Note that file extension is still .php.

2 ) NAMING CONVENTIONS FOR PHP ELEMENTS (REQUIRED):
Follow the guidelines given below to name elements during PHP code development.
a) Use camel case for all the naming across elements whether variables, functions, classes,etc.
b) Each element name should be preceded by its nature/the type of content it is supposed to
hold. This prefix should be lowercase, and different from the actual keyword being used to
declare/define the element in question
c) The name should be intuitive and clearly express the purpose of the element however not
redundantly long Some of the examples are given below fro quick reference.
i) Variables should be named as intCount for Integer type of data floatTotalSalary for
float type of data
ii) Arrays should be named as arrEmpData
iii) Classes should be named as clsEmpData
iv) Constants should be named as cnstMaxSalary
v) Global Variables: As an exception, global variables should be named as below.
_TOUT_COOKIE for global variables.
Please note that underscore as prefix and all uppercase characters.

To be continued.....

Contact us for Software Outsourcing and iPhone Software Development