In recent years, the World Wide Web (also known as global Information Network, or WWW) has changed the face of information processing technology. The web has quickly become an effective medium and is suitable for people and business communication and collaboration. Almost all of the information technology areas are generally affected by the web. Web Access brings more users and more data, which means more pressure on servers and databases and slower response times for end users. Web Dynamic Web Surface statics should be a more practical and cost-effective alternative to increasing CPU, disk drives, and memory to keep up with this growing demand.
Implement the concrete implementation function of Web Dynamic Web page static using PHP as shown in function Gen_static_file ()
function Gen_static_file ($program, $filename)
{
$program 1= "/usr/local/apache/htdocs/php/". $program;
$filename 1 = "/usr/local/apache/htdocs/static_html/". $filename;
$cmd _str = "/usr/local/php4/bin/php". $program 1. " } " . $filename 1. " ";
System ($cmd _str);
Echo $filename. "Generated.〈br〉";
}
This function is the key to the implementation of static, that is, the PHP dynamic page program is not sent to the browser, but instead entered into a file named $filename (2). Two parameters $program is a PHP dynamic page program, $filename is the name of the generated static page (it is important to make the naming rules on your own, as you see below),/usr/local/php4/bin/ PHP is a part of PHP that has the ability to program input files, and the system is a function of executing external commands in PHP. 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 the specific needs).
Let's take a concrete example to see how college_static.php static pages are generated.
function gen_college_static ()
{
for ($i = 0; $i 〈=; $i ++〉
{
Putenv ("province_id=". $i); *.php files are used when fetching data from a database.
$filename = "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 is statically converted into 33 static pages college.static0.html~ College.static33.html, where $filename will change with the change of $i. Of course, you can also directly from the database to control the number and name of the static page generated, other programs on the generated static page calls should be consistent with the naming rules of static pages.
http://www.bkjia.com/PHPjc/445161.html www.bkjia.com true http://www.bkjia.com/PHPjc/445161.html techarticle in recent years, the World Wide Web (also known as global Information Network, or WWW) has changed the face of information processing technology. The web has quickly become an effective medium and suitable for people and business communication ...