Beginners PHP, you may encounter the PHP naming problem, here will introduce the PHP naming rules, hope can help everyone, careful friends can write down to stay as a future study material.
1. Proper naming of PHP naming rules
Naming is the core of program planning. The ancients believed that knowing a person's real name would gain an incredible power over that person. As long as you think of the right name for something, it will give you and later people a stronger power than the code. Don't laugh! A name is a long and far-reaching result of things in the ecological environment in which they are located. In general, only the programmer who understands the system can get the most appropriate name for the system. If all the names are compatible with their nature, then the relationship is clear, meaning can be deduced, and the general presumption can be expected.
If you find that only a small amount of your name can match its counterpart, it's best to take a good look at your design again.
2. Naming the PHP naming rules class
Before you name a class, you must first know what it is. If you still can't figure out what this class is, then you're not doing a good job with the kind of clues that the class name provides. A mix of more than three words is prone to confusion among entities of the system, and then look at your design and try to use the CRC Session card to see if the named entity has so many functions. The name of the derived class should avoid the temptation to take its parent class name, which is related only to itself and not to what its parent class is called. Sometimes the suffix is useful, for example: If your system uses a proxy (agent), then a part is named "Download Agent" (downloadagent) to actually transmit the information.
3. PHP naming rules methods and function naming
Usually each method and function performs an action, so naming them should clearly explain what they do: Replace Errorcheck () with Checkforerrors () and Dumpdatatofile () instead of datafile (). Doing so can also make the function and data a more distinguishable object.
Sometimes the suffix name is useful:
Max-means the maximum value that an entity can give.
Cnt-The current value of a running count variable.
Key-value.
For example: Retrymax represents the maximum number of retries, and retrycnt represents the current number of retry attempts.
Sometimes the prefix name is useful:
IS-meaning to ask a question about something. Whenever people see is, they know it's a problem.
Get-meaning to get a numeric value.
Set-meaning to set a value
4. Do not use all uppercase letters for the PHP naming rule abbreviations
In any case, you can use the first letter to capitalize the remaining lowercase letters to represent abbreviations in lieu of all uppercase letters. Use: Gethtmlstatistic. Not used: gethtmlstatistic. Reason: When naming contains acronyms, people seem to have very different instincts. Uniform rules are the best, so that the meaning of naming can be fully predictable. As an example of networkabckey, note that C is the C in the ABC or in the key, which is very confusing. Some people don't care about this, others hate it. So you'll see different rules in different code, so you don't know how to call it.
For example:
- Class Fluidoz//Do not write Fluidoz
- Class Gethtmlstatistic//Do not write gethtmlstatistic
http://www.bkjia.com/PHPjc/446452.html www.bkjia.com true http://www.bkjia.com/PHPjc/446452.html techarticle Beginners PHP, you may encounter the PHP naming problem, here will introduce the PHP naming rules, hope can help everyone, careful friends can write down to stay as a future study material. 1 .... .