Accepted designations
To facilitate the perception of program code and for compatibility of modules of different developers, we strongly recommend using the following rules when choosing names for variables and functions:
Type | Description | Example |
---|---|---|
Name of root scripts | Lower case with word separator - underscore. | index.php, goods_compare.php |
Name of modular scripts | The first word in the name of the script is the name of the company or its abbreviation, the second word is the name of the group into which the modules are grouped, and finally, the third and subsequent words are words at your discretion, explaining what the script does. Underscores are used as separators between words. | melbis_inc.php, melbis_web_test.php, melbis_cataloge_sub.php. |
Function names in modular scripts | Every regular module script (except for module-libraries) must have a main function that is called automatically. The main function of a module is named the same as the script itself, but entirely in uppercase. Other functions in the script are specified in lower case with words separated by an underscore. The name of the main function should be prefixed at the beginning of their names. This ensures the uniqueness of function names and improves code readability. If you use a function from the library, you can determine which script it is in by its name. |
Module name: melbis_web_test.php The main function of the script: function MELBIS_WEB_TEST($mVars) Auxiliary function: function MELBIS_WEB_TEST_func($mId, $mName) |
Name of keys in HTML templates | Upper case; underscore as word separator. | {MAIN}, {PAGE_NAME}, {HTML_CODE} |
Global variables in scripts | Start with a lowercase "g", then capitalize each word. Abbreviations are written as normal words. It is recommended to use the name $gParser for the parser, for the code autocompletion function to work. | $gParser, $gTitleHtmlPage |
Local variables inside scripts | Lower case; underscore as a word separator. For SQL queries it is recommended to use $command variable for automatic SQL syntax highlighting. | function any_value() { ... $i = 1; $item_count = 5; .... } |
Input variables for functions | Begin with the letter "m" in lower case, then capitalize each word thereafter. Abbreviations are written as regular words. In the main function of modular scripts, it is recommended to use the $mVars variable for the array of input parameters. | function MELBIS_WEB_TEST_func($mId, $mName) { ... } function MELBIS_WEB_TEST($mVars) { ... } |
Constants in PHP scripts | All letters are uppercase; underscores are used as word separators. | define('FOLDER', './'); define('DB_NICK', 'MS'); |