Variable Naming Best Practices
Mecha has some disciplines in naming their variables.
General
Reserved variables in Mecha should match to ^[a-z]+(?:_[a-z\d]+)*$ pattern:
$siteUser variable style should be prefixed by a _ to prevent collision with the reserved variables:
$_siteNote: If for a reason, the reserved variables are overwritten, you can always restore the original variable value by accessing the global variables stored in $GLOBALS:
$site = null; // :(
echo $site->title; // :'(
$site = $GLOBALS['site']; // :)
echo $site->title; // :*Namespace
Another way to safely writing variables is by namespace-ing your variable name:
$my_siteOthers
Common variable names using a letter with their meaning:
$a→ array container$b→ base$c→class, configuration$d→ directory$e→ evaluate$f→ file$g→ results of thegandglobfunction$h→ hint$i→ increment, integer, number$j→ length of the$a(used inforloop)$k→ array key$l→ ?$m→ matches$n→ name$o→ array container, output container$p→ page, path$q→ query$r→ return value$s→ placeholder, universal variable$t→ title, text$u→ URL, URL part$v→ array value$w→ word$x→ test, file extension$y→ ?$z→ ?
0 Comments
No comments yet.