Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Code Analysis of php instance

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this article Xiaobian for you to introduce in detail "php example code analysis", the content is detailed, the steps are clear, the details are handled properly, I hope this "php example code analysis" article can help you solve your doubts, following the editor's ideas slowly in-depth, let's learn new knowledge.

Things that you often do and think about.

Obscure if condition

1) for the processing of |

The above code takes more time to understand than the following code

While reducing the number of lines of code is a good goal, minimizing the time required to understand the code is a better goal.

Return value

The "$ret" above is an excuse for "I can't think of a name". Instead of using such an empty name, choose a name that describes the value or purpose of the entity.

Alias declares that the variable is used to host the alias-- indicating the purpose of the variable. And may help us find defects.

A good name should describe the purpose of the variable or the value it carries.

Temporary variable

The $I here is "my temporary variable", which is specially used to increase the statistics automatically and avoid the repetition of statistical points. But the most important thing for this $I is not the temporary variable. Using charset_index to represent "subscript of my statistics" is more "descriptive".

Cyclic iterator

I also found a bad smell in my js code.

The I variable name is vague, so don't do this.

Names such as iMagol, JJournal, ITER and it are often used as indexing and loop iterators. Although the names are vague, everyone knows that they mean "I am an iterator". In fact, if you use these names to mean other meanings, it will be very confusing. So don't do this.

If you have to use a vague name like iGrainjjjit, then you have to have a good reason to convince yourself.

After reading this, the article "php example Code Analysis" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, you are welcome to follow the industry information channel.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report