You need to use a browser that supports CSS Grid Layout.
If you are using MS Internet Explorer, try using Edge, Chrome, Firefox or Safari.

Coding Standards for PHP

Now that I am starting to use PHP as a programming language I have mashed up a short set of standards that I hope will make it easier for anyone sharing in phpAgile framework development.

These standards are based pretty much on the standards provided for the Fuel framework (see ).

PHP Files

Short tags

Do not use the PHP short tag option (ie. use <?php ... not <? ... ). Check your PHP.ini file and see the note:

“ Using short tags should be avoided when developing applications or libraries that are meant for redistribution, or deployment on PHP servers which are not under your control, because short tags may not be supported on the target server. For portable, redistributable code be sure not to use short tags ”

File Names

User lower case (with underscores if necessary).

Naming Conventions


Class names should use title case (with underscores to separate words if necessary).


Method names should use lower case (with underscores to separate words if necessary)

class Person 
    public static function get_where($name, $data)
        // Some code here


Variable names should be concise, and contain only lower case letters and underscores. Loop iterators should be short, preferably a single character.

for ($i = 0; $i < $max; $i++)


Constants should be all upper case.



Keywords such as true, false, null, as, etc should be all lower case. (also for primitive types like array, integer, string).

$var = true;
$var = false;
$var = null;
while($row = $result->fetch())

SQL Statements

SQL keywords should be upper case with lower case table and field names

SELECT id, forename, surname, email, status 
    FROM members 
    WHERE status = 'member';

Code formatting


Use one tab (not spaces) for each level of nesting, but align code after the indentation with spaces (not tabs).

// indent 1 tab
$membership = 'Affiliate';  // indented with tabs 
$status     = 'Member';     // aligned using spaces

Control Structures

Code groups (such as if, for, foreach, while, switch) and Function and Method structures should be followed by a space as should parameter/argument lists and values. Braces should be placed on a new line, and break should have the same tab as its case.

  if ($arg === true)
    // do something here
  elseif ($arg === null)
    // do something else
    // otherwise
  while ($row = $result->fetch())
    // loop here
  switch ($status)
    case 'value1':
      //do something here
    default :
      //do something here
  public function get_where ($value, $data)
    // code here


When initializing variables, one variable should be declared per line. To enhance code readability these should each be on a separate line. Align values and comments when appropriate.

  $id         = 1234;    // do each on its own line
  $forename   = 'John';
  $surname    = 'Gallagher';
  $membership = 'Full'; 

Brackets and Parenthesis

No space should come before or after the initial bracket/parenthesis. There should not be a space before closing bracket/parenthesis.

$array = array(1, 2, 3, 4);
$array['index'] = 'something';
for ($i = 0; $i < $max; $i++)


String concatenation should not contain spaces around the joined parts

$string = 'Total value: '.$total.' (excl. VAT)';


In general operators will have a space before and after (except for the ++ incrementor)

$var = 'something';
if ($var == 'something') 

<<  back to Blogs page