In recent years, the World Wide Web (also known as Global Information Network, or WWW) has continuously changed the face of information processing technology. WEB has quickly become an effective medium and is suitable for people and businesses to communicate and collaborate. Almost all information technology fields are generally affected by WEB. Web access brings more users and more data, which means more pressure on servers and databases and end users get slower response speeds. Compared with the continuous increase in CPU, disk drives and memory to keep up with this growing demand, static WEB dynamic web pages should be a more practical and economical option.
The specific implementation function of using PHP to implement static WEB dynamic web pages is shown in function gen_static_file()
This function is the key to achieving staticization, that is, the PHP dynamic page program is not sent to the browser, but is input into a file named $filename (as shown in Figure 2). Among the two parameters, $program is the PHP dynamic page program, $filename is the name of the generated static page (you can formulate naming rules yourself as needed, which is very important, see below), /usr/local/php4/bin/php is the part of PHP that has the function of entering the program into files, and System is a function in PHP that executes external commands. We can also see that all php programs that generate dynamic pages need to be placed in the /php/ directory, and all newly generated static pages will appear in the /static_html/ directory (these paths can be set according to specific needs).
Let's give a specific example below to see how the static page of college_static.php is generated.
From this function we can see that by calling the function gen_static_file(), college_static.php has been statically transformed into 33 static pages college.~college., where $filename will change with the change of $I. Of course, you can also directly take values from the database to control the number and name of the generated static pages. The calls to the generated static pages by other programs should be consistent with the naming rules of the static pages.
The specific implementation function of using PHP to implement static WEB dynamic web pages is shown in function gen_static_file()
function gen_static_file($program, $filename) { $program 1= "/usr/local/apache/htdocs/php/" . $program; $filename1 = "/usr/local/apache/htdocs/ static_html/" . $filename; $cmd_str = "/usr/local/php4/bin/php " . $program1 . " } " . $filename1 . " "; system($cmd_str); echo $filename . " generated.〈br〉"; } |
This function is the key to achieving staticization, that is, the PHP dynamic page program is not sent to the browser, but is input into a file named $filename (as shown in Figure 2). Among the two parameters, $program is the PHP dynamic page program, $filename is the name of the generated static page (you can formulate naming rules yourself as needed, which is very important, see below), /usr/local/php4/bin/php is the part of PHP that has the function of entering the program into files, and System is a function in PHP that executes external commands. We can also see that all php programs that generate dynamic pages need to be placed in the /php/ directory, and all newly generated static pages will appear in the /static_html/ directory (these paths can be set according to specific needs).
Let's give a specific example below to see how the static page of college_static.php is generated.
function gen_college_static () { for ($i = 0; $i 〈= 32; $i++〉 { putenv("province_ college_static". $i . ".html"; gen_static_file("college_static.php", $filename); } |
From this function we can see that by calling the function gen_static_file(), college_static.php has been statically transformed into 33 static pages college.~college., where $filename will change with the change of $I. Of course, you can also directly take values from the database to control the number and name of the generated static pages. The calls to the generated static pages by other programs should be consistent with the naming rules of the static pages.