DZ Forum Core Code Analysis plan-Comment _php tutorial

Source: Internet
Author: User
DZ Forum in the domestic market is the largest application. The customer may use the code that is not focused on its intrinsic quality, but this code core is indeed the best tutorial for beginners in PHP.
Online to find out, there is no detailed analysis of files or analysis of the list. Since PHP represents the open source represents the share. Why don't you do it?
Moreover DZ's code style is very smooth, looks very comfortable. And there are a lot of good habits and ideas in the inside, can learn a lot of things.

Start profiling from index.php under the root directory. I know that DZ adopts a self-created template system. and very useful. But I'm not going to start with an include file package based on my online friends ' experience. Because the idea is too scattered. So I started analyzing the code based on the habits of the page. It is expected that another part of the 3-day period will be
This series of stickers is my preliminary analysis. Just a simple analysis of its structure and code-building thinking with my own thoughts. When all the work is done, at the current speed (because I have to go to work, no time to jump on it every day). One months all the preliminary analysis can be completed roughly. Then the next task is to conduct careful analysis and application according to the preliminary analysis. This is roughly how my PHP self-study process is arranged.
I hope this thing is effective for friends who learn the same way as I do.
In fact, I created a file directory and a table, but now the content of the analysis is relatively small. So I don't send it up for the time being. When all is done and then released.
Description: is based on the latest DZ6.1 core code! On the document, I have my own judgment on some of the functions of the process of each step is detailed, and some did not make it very clear just to explain the function of the approximate role. If you want to analyze it based on my comment version. Comments are a reference element for everyone. If there are no comments correctly, please keep abreast the instructions. Thank you. Attached to my summary notes is to share what I learned from the code
Would like to have and I am equally interested in studying DZ of the same-minded people send forum knives to me. Crowds ha ~

Loading the first article: 1, DZ Forum Core Code Analysis plan--install Package

I have started the analysis from the first install file package. The analysis is complete.
Install Chapter
The following is a description of the source file is written ... A lot of ideas worth borrowing from. Just leave a hole in here ... Because the things on my computer are still in disorder. A certain day of the year, I accidentally put my integrated code disk completely deleted .... It collapsed and collapsed.
The analysis is not in every line, that's too trivial. This analysis only analyzes his thoughts and thoughts. Method is the most important. The function is readily available for inspection.

Below, is my analysis diary. The analysis was done in 2 days. It's quite simple. But a lot of things I seldom use, but it is useful. worthy of reference.

The following is the referenced content:
October 3, 2008 17:46:52
Analysis File: install/index.php
1.
Introduce the error_reporting () method at the top of the code to set the error level for PHP. In fact, the PHP configuration file can be configured, but in each file reset this error level, make the error prompt more flexible.
2.
Under certain conditions, the run time is set by using Set_time_limit (), and the output buffer is opened via Ob_start (). It is best to use @ To mask errors.
3.
Use define () to set multiple constants rather than variables for use by program code.
Analysis File: discuz_version.php
File function: Defines the constant value of the copyright
1.
Because this file is introduced to call its set constants. So theoretically any file can be called. So at the beginning, by judging whether In_discuz is true, if not, stop the whole program from running.
October 4, 2008 9:42:22
Analysis File db_mysql.class.php
File function: Database link class
1.
Deciding whether to use mysql_connect (non-sustainability) or mysql_pconnect (persistence) through a judgment
2.
Deciding whether to use Mysql_unbuffered_query (to perform an action but not return any data) or mysql_query (to perform an operation that returns data)
3.
1 and 22 experience points, a lot of use? : operator; (EXP1?): (EXP2):(exp3)). If the EXP1 is true then Exp2, and vice versa Exp3.
4.

Mysql_num_fields-get the number of fields in the result set
function Num_fields ($query) {

Return Mysql_num_fields ($query);

}
5.
Releasing the resulting memory

function Free_result ($query) {

Return Mysql_free_result ($query);

}
October 4, 2008 10:21:48
Summary: Since the included files can be accessed through a path, DZ defines a constant in_discuz in front of all references to other files in order to protect the security of the file. This constant is judged on the head of the file being introduced, if there is no constant, which is accessed directly through the path. No part of the source code is executed. This is a good source of protection code measures. And it's simple.

Also, when analyzing the install package, I found that the DZ Programmer's thinking is really good. Consider many of the errors that occur and process them. To be honest, I really can't do that. Worth learning. And it considers the database or PHP version of the problem, in the db_mysql.class.php file used a dynamic set of data storage encoding method. We can use it for reference.

http://www.bkjia.com/PHPjc/364111.html www.bkjia.com true http://www.bkjia.com/PHPjc/364111.html techarticle DZ Forum in the domestic market is the largest application. The customer may use the code that is not focused on its intrinsic quality, but this code core is indeed the best tutorial for beginners in PHP. Online ...

  • 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.