PHP Coding standards

 PHP Coding Standards:

Below are the practices every programmer should follow for clean and neat code. By following these code will be readable and easily understandable by other fellow programmer.


There should be comments in appropriate format.

Do not use short tags as it creates confusion

There 2 naming conventions we can follow

Consistently Using Braces

BSD style

K&R style

Using Loops in appropriate ways

Avoiding Deeply Nested Loops

Variable Names:

handling word breaks in multiword variable names



Function Names

  • They should be all lowercase, and multiword names should be separated by underscores.
  • A function’s, class’s, or variable’s name should always reflect what that symbol is intended to do, to enhance the readability of your code

Naming Consistency

  • Variables that are used for similar purposes should have similar names
  • Matching Variable Names to Schema Names
  • Variable names that are associated with database records should always have matching Names
Avoiding Using Open Tags

PHP allows the use of so-called short tags, like this:


echo “Hello $username”;



using short tags makes it impossible to print normal XML documents inline because PHP would interpret this header as a block and will attempt to execute it:

<?xml version=”1.0” ?>

You should instead use long tags, as in this example:


echo “Hello $username”;

? >


Avoiding Using echo to Construct HTML


Using Parentheses Judiciously


Tag Description

@package [package name] The package name

@author [author name] The author information

@var [type] The type for the var statement following the


@param [type [description]] The type for the input parameters for the

function following the block

@return [type [description]] The type for the output of the function


Popular posts from this blog

Reasoning Syllolism Quiz

Career opportunities as a web developer