In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "naming rules of PHP". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Naming with appropriate PHP naming rules
Naming is the core of program planning. The ancients believed that as long as they knew a person's real name, he would gain incredible power over that person. As long as you give things the right name, it will give you and later people more power than the code. Don't laugh! A name is a long-term and far-reaching result of something in its ecological environment. In general, only programmers who know the system can come up with the most appropriate name for the system. If all the names are suitable for nature, the relationship is clear, the meaning can be deduced, and the inference of ordinary people can be expected.
If you find that only a few of your names match their counterparts, take a fresh look at your design.
2. PHP naming convention class naming
You need to know what a class (class) is before you name it. If you still can't remember what the class is through the clues provided by the class name, then your design is not good enough. A mixed name consisting of more than three words can easily cause confusion between various entities in the system. Look at your design and try to use (CRC Session card) to see if the entity corresponding to the name has so many functions. The temptation to name a derived class with its parent class name should be avoided. The name of a class is only related to itself, not to what its parent class is called. Sometimes a suffix is useful, for example, if your system uses an agent, then name a part "download agent" (DownloadAgent) to actually transmit information.
3. PHP naming rules, methods and function naming
Usually each method and function performs an action, so naming them should clearly indicate what they do: use CheckForErrors () instead of ErrorCheck (), and DumpDataToFile () instead of DataFile (). Doing so also makes functions and data more distinguishable objects.
Sometimes a suffix is useful:
◆ Max-means the * * value that can be assigned by an entity.
◆ Cnt-the current value of a running count variable.
◆ Key-key value.
For example, RetryMax represents the maximum number of retries, and RetryCnt represents the current number of retries.
Sometimes prefixes are useful:
◆ Is-means to ask a question about something. Whenever people look at Is, they will know that this is a problem.
◆ Get-means to get a numeric value.
◆ Set-meaning to set a numeric value
4. Don't use all uppercase letters for PHP naming convention abbreviations
In any case, when you encounter the following situations, you can use the first letter uppercase and the rest lowercase instead of using all uppercase letters to express abbreviations. Use: GetHtmlStatistic. Do not use: GetHTMLStatistic. Reason: when naming contains acronyms, people seem to have very different intuitions. The uniform rule is *, so that the meaning of naming is completely predictable. In the case of NetworkABCKey, it is puzzling to note whether C should be C in ABC or C in key. Some people don't care about it, while others hate it. So you will see different rules in different code, so you don't know how to call it.
For example:
Class FluidOz / / Don't write as FluidOZ class GetHtmlStatistic / / Don't write as GetHTMLStatistic "naming rules for PHP". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.