PHP coding standard
As with any programming language, following naming conventions ultimately makes your code easier to read and maintain. Here's a few rules to follow:
*Class names use PascalCase.
*Method names should be in camelCase.
*Constants require all capital letters, separating each word with an underscore (e.g. CONSTANT_VARIABLE).
There's more, follow these guidelines as well:
* Only use
* Files should either declare symbols or use them.
* Files must be in UTF-8 format without BOM for PHP code
The Advanced Coding Standard
* Four spaces should be used instead of tabs.
* The ideal line length should be under 80 characters, but a soft limit of 120 characters should be imposed on all lines.
* There should be one blank line under the namespace and use declarations.
* A method's or class's opening brace must be on its own line.
* A method's or class's closing brace must go on the line immediately after the body.
* All properties and methods require a visibility level.
* The 'abstract' / 'final' keywords should appear before the visibility while 'static' goes after.
* Control structure keywords must be followed by one space.
* A control statement's opening brace should appear on the same line as the statement.
Most of these are self-explanatory, but the middle convention is slightly confusing. It essentially dictates that any declaration, be it functions, classes, etc., should be separated into their own files. This not only promotes best practices like code-reuse and separation, but it keeps your code neat and clean.