Updated on Kisan Patel
Variable names or identifiers should be very descriptive. I have seen scripts where all the variables were named $var1, $var1, $var2, and so on. It may seem straightforward to name variables like this, but two years from now when you come back to the script, it will take forever to figure out what information is in each variable. PHP won’t care or get confused, but humans trying to follow the script will have a hard time. Make your scripts much easier to understand by using descriptive variable names like $firstName, $directory_name, or $DateOfBirth.
The rules for variable names are as follows:
Assigning variable names is a matter of personal style. Creating descriptive variable names by connecting words with an underscore or by using uppercase letters to denote the beginning of new words (often called camel caps) are the two most common variable naming styles, as shown here:
Naming your variables by using one of these two common styles makes it easier for other programmers to read your scripts. It’s also common to start the name with a lowercase letter. The most important factor in naming variables, however, is to be consistent. Pick a style and use it throughout the entire script.