Modular design of the php--
[Source] Dahne [edit] Dahne [Time]2012-10-30
The navigation module can be simply listed as an HTML file for a three-level page link. Usually you can indicate the area of the site to which the user is currently located by indicating a link to the current area with another color. Navigation can be a list of links on the left side of the page
HP's include and require in the two functions, can be in the design of the site to improve the site's construction efficiency and maintenance, now detailed explained below:
The Include function differs from the preprocessing command of the same name in C, which is a given file name (for example: include (Test). PHP), PHP applies the file to the include location, and tries to interpret the file, which differs from the function in that the code is parsed only when the include statement is executed, so it is often used in the design to include the call in the IF statement; require The H number always contains the specified file, even if it is in a place that is not executed in the IF statement. You can see this in the discussion of the PHP mailing list: Require is faster than include, because PHP can insert the specified file into the script in the early stages of the read-through code. So in the program design, if a file is contained in a control block (for example: if,switch,while,for), use include, and other cases use the REQUIRC function.
Why should we use include and require in PHP? First, because this makes the code more readable, and secondly, it can be divided into modules, which allows you to design in the site as long as you write the script to be reused, can be used throughout the construction of the site and subsequent project reuse, It does not require you to repeat the work, greatly improving the efficiency. Many web sites must rely on repetitive features, such as a consistent navigation bar, which makes it easy for users to operate, but is a big problem for building and maintaining site D. Each page has a code block that must be duplicated on top of it. Make it into a module and include or rquire it in each of the required pages, and modify it only once, that is, only the script module of the include can be modified. So in the construction of a website, should analyze the site that part is duplicated? Then write the duplicated code in the module. Here is a way to partition the site module:
0, Information screen 1, database and file action 2, H number 3, layout 4, navigation bar.
The detailed measures are as follows:
The core of the site is the information page it contains, and everything else is dotted. The screen can be either HTML or PHP code that extracts and formats data from a database or file, which can continue to be divided into sections based on their number, which is more useful for maintenance than other methods. The modules on the first screen correspond to the pages that are accessible on the site. Depending on where the page appears on the site, you have the appropriate navigation and layout. This Information screen module becomes the key to select the remaining modules. such as the website of the press release system.
The navigation module can be simply listed as an HTML file for a three-level page link. Usually you can indicate the area of the site to which the user is currently located by indicating a link to the current area with another color. The navigation can be a list of links on the left side of the page. Each button is an image. They change when the mouse is passed. You can create a module that determines the area based on the selected screen module. In contrast, it is easier to use an if statement to display a transformed version of a link to the current region.
When you build your site, it is very likely that you will encounter repeated snippets of code. function modules can be used to put these functions up.
All right, the introduction of include and require is here, I believe it will help you in the construction of the website. The application of include and require in the encapsulation of the next database operation is expected to help the big understanding and play a role.
Modular design of the php--