Skip to content

PHP Course Coding Standards

All code written for this course should follow the PSR-12: Extended Coding Style which also requires adherence to the PSR-1: Basic Coding Standard.

Acceptable deviations from the standard include the vertical allignment of curly braces (i.e.):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
if ($age >= 18)
{
    echo "Old enough to vote!";
}
elseif ($age >= 16) 
{
    echo "Old enough to drive!";
}
else
{
    echo "Sorry!";
}

vs.

1
2
3
4
5
6
7
if ($age >= 18) {
    echo "Old enough to vote!";
} elseif ($age >= 16) {
    echo "Old enough to drive!";
} else {
    echo "Sorry!";
}