Home >Backend Development >PHP Tutorial >How to read a PHP source code_PHP tutorial

How to read a PHP source code_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:44:251087browse

A good source code, such as dz forum, wind forum, empire cms, dedecms, etc., all have their own set of design ideas and design patterns, so you must be mentally prepared before looking at a certain product, and you can put your own Compare your experience with these products, but don’t always judge with your own thinking. In one sentence, "look at it with the dialectical thinking of learning and criticism."
Okay! Let’s get started!
So specifically how do we read a PHP source code?
1. First install the source code, combine it with its documentation and manuals, and become familiar with its functions and its application methods.
Two. Browse the directory structure of the source code and understand the functions of each directory.
Three. After going through the above two steps, I believe you have a preliminary understanding of this open source product, so start analyzing its source code now. In this step we start to analyze the source code framework. For example, whether the entrance method is single entrance or multiple entrances, and the calling rules between pages, the pages used by a certain function can be found based on the rules.
Four. Be familiar with the code writing style of source code, such as indentation, formatting, etc.
Five. To get familiar with the databases and tables used in the source code, you can refer to its technical support documentation.
Six. After the above steps, I believe everyone has a deeper understanding of this source code, but this understanding is only superficial. Let’s analyze it in detail from 6 aspects:
1. Entry structure and page The specific implementation of the calling method. If you see tool classes and tool functions while reading, try to familiarize yourself with them. This step of analysis can learn the system architecture of the source code.
2. Analyze the tool classes and tool functions used in the source code, so that you can learn a lot of programming skills. You can improve your programming skills.
3. Combined with some security rules, study how this source code implements security design. This can improve your awareness and skills in safety.
4. If there is a template engine, study the source code template engine. Roughly consider several aspects such as implementation, efficiency, and ease of use.
5. Study the various functional modules of the system, so that you can not only learn programming skills but also open up your own programming ideas. Next time you encounter something similar, you will have an idea.
6. Research the design patterns used in the system. The same functional implementation may use very different design patterns. Comparing the design patterns we have done before is the only way to improve our control of code.
7. Study the source code’s optimization of access pressure, execution efficiency, system efficiency, and database queries.
Methods are just ways and tools, and specific practice requires everyone’s efforts. My opinion is don’t be anxious, analyze it carefully, and apply the analysis results to your specific projects, haha!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320573.htmlTechArticleA good source code, such as dz forum, wind forum, empire cms, dedecms, etc., all have their own A set of design ideas and design patterns, so you must be mentally prepared before looking at a product...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn