How to read/analyze a source code for PHP Open source program

Source: Internet
Author: User
One of the reasons to like PHP is that she has countless open source programs http://phpxref.com/home/code-library, a lot of good code for you to take in your hand to peruse!

Analyzing source code It's like going to a new place and needing a map!

Q: How to analyze a PHP open source program? How can I get more knowledge in the code?

Reply content:

One of the reasons to like PHP is that she has countless open source programs http://phpxref.com/home/code-library, a lot of good code for you to take in your hand to peruse!

Analyzing source code It's like going to a new place and needing a map!

Q: How to analyze a PHP open source program? How can I get more knowledge in the code?

Upstairs, I will run the program first, and then find the features I am interested in, from the implementation of the function of the page to look at the side of the screen to try to further modify the file to achieve their desired effect. Through many changes (in fact, this process is the code reading and analysis), you can probably understand the connotation of each.

I have summed up some of the methods, to initiate;-)

General Analysis:

1. Software use on functional analysis-large direction to understand the business logic of the program;
2. Directory structure-roughly analyze the meaning of each folder and file;
3. Database structure-The goal of the program is to data, analysis of database logic design, specific to each field design, can have a good understanding of the program!
4. Design mode-Research design mode, there is a sentence to put all the PHP into the same file, the program still works
5. Code Analysis-Starting from the initial request of the page, simulate the PHP parser to see the code, mainly from the business logic of the initial division of Code;

Programming Analysis:

1. Template system analysis, if any
2. Caching mechanism analysis, if any
3. Plugin mechanism, if any
4. Extensibility Analysis
5. Security mechanism Analysis
6. Study the source code on Access pressure, execution efficiency, system efficiency, database query optimization.

I'm used to finding the entrance, and then the process is going through, and I'll see the details later.

I usually run the program first and then change the code inside to see what happens.

I can't program, but if I go read a source code. The first is to look at official documents, clear file layout, grammar specifications, familiar with the construction of the program, and database structure, and then layered to carefully read each function implementation of the process.

I will start from the page portal to see a general understanding of the composition of the content of the page, and then sequentially according to the function to fall back to the corresponding file for reading. After reading the content of a page, on the one hand, the part of the code package to understand the use of regular functions, on the other hand, a general understanding of the code package file structure. On the basis of this file structure, it analyzes its internal object structure and reads the object class library from the bottom up according to the inheritance relationship.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.