Variable Naming
The Variable Naming standard you choose, can be anything you want, bearing in mind that different languages have restrictions on what can be used to name variables, and some keywords are banned from being included in variable names. Some languages are also case sensitive, or insensitive, and that also has as effect on variable names.
Variables in Php
The variable name is case-sensitive and starts with a letter or underscore, followed by any number of letters, numbers, or underscores.
Variable Naming Tips
1) Choose a standard, that comes naturally to you, and one that will adequate describe the variable and the use of the variable. Also insure that the naming standard you choose, if you are having multiple members on your team, that everyone sticks to the same standard.
$website_name = “Php Tutorial Site”;
2) Iteration and other loops, you can use the “known” variables that are associated with iterations
$ index;
$indx;
$ndx;
$n;
$i;
$count;
$counter;
While these variables do not appear descriptive, when it comes to loops, they describe the functionality very well, and that usage is commonly known in the programming world.
3) Using Upper and Lower Case
This helps in making the name of the variable easy to read, as it provided a break to the eyes, and help the programmer to understand that variable and it purpose. This helps to show the normal speak break that is associated when joining 2 or more words.
$fullname;
$FullName;
$myfirstbook;
$MyFirstBook;
$phptutorialsite;
$PhpTutorialSite;
4) Using the underscore is another way to join word, and provide the natural breaks, just as we did with the Upper and Lower Case, we can also use the _ underscore, in conjunction with the Upper and Lower Case to get full effect and making the variable names easy to use.
$mywebsitename=”Php Tutorial Site”
$my_website_name = “Php Tutorial Site”;
$MyWebsiteName = “Php Tutorial Site”
$My_Website_Name= “Php Tutorial Site”
Alogn with writing comments in your PHP program, having descriptive variable names is an effective technique in reducing the number of hours spent programming and debugging.


