Function Declarations

As previously stated, functions should have a comment block explaining what they do and their input/output. The function block should align starting at one tab from the left margin unless the function is part of a class definition. Opening and closing braces should also be one tab from the left margin. The body of the function should be indented two tabs.

<php
        /*
        ** doAdd
        ** Adds two integers
        ** Input:  $a, $b
        ** Output: sum of $a and $b
        */
        function doAdd($a, $b)
        {
              return(a+b);
        }
?>

Get Core PHP Programming: Using PHP to Build Dynamic Web Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.