There are two static page Methods: pseudo-static, URL rewriting, and static. The following describes the Static Page Method in PHP. In PHP website development, full-site or partial static processing is required for website promotion and Seo. php provides multiple methods to generate static html pages, for example, to use PHP templates and cache to achieve static pages, we will discuss how PHP generates static pages in the form of PHP instance tutorials today. What is Php static PHP static simple understanding is to make the website generated pages appear in the form of Static HTML in front of visitors, PHP static divided into pure static and pseudo static, the difference between the two is that the processing mechanism for generating static pages in PHP is different. PHP static html page generation method 1 It is very convenient to use PHP templates to generate static page PHP templates to achieve static, such as installing and using PHP smarty to achieve static website. 2 Use the PHP file read/write function to generate a static page PHP to generate a static page instanceCode <? $ Out1 = "<HTML> $ Fp = Fopen ("Leapsoulcn.html", "W "); If (! $ Fp ){ Echo "System error "; Exit ();} Else { Fwrite ( $ Fp , $ Out1 ); Fclose ( $ Fp ); Echo "Success" ;}?> 3Use the PHP Output Control Function (output control) to generate a static page output control function, that is, use and control the cache to generate a static html page, and use the PHP file read/write function. PHP generates static page instance code <? Ob_start (); Echo "<HTML> ". " $ Out1 = Ob_get_contents (); Ob_end_clean (); $ Fp = Fopen ("Leapsoulcn.html", "W "); If (!$ Fp ){ Echo "System error "; Exit ();} Else { Fwrite ( $ Fp , $ Out1 ); Fclose ( $ Fp ); Echo "Success" ;}?>We know that PHP is used for website development. Generally, the execution results are directly output to the browser. To generate a static page using PHP, you need to use the output control function to control the cache to obtain the content in the cache, and then output to the static html page file to achieve static website. The idea of generating static pages in PHP is: first enable caching, then output HTML content (you can also include HTML content in the form of a file through include), and then get the content in the cache, after the cache is cleared, the PHP file read/write function writes the cached content to the static html page file. PHP file read/write tutorial? The process of obtaining the output cache content to generate a static html page requires three functions: Ob_start (), Ob_get_contents (), Ob_end_clean (). Knowledge point: 1 The ob_start function is generally used to enable caching. Note that no output, such as spaces or characters, is allowed before the ob_start function is used. 2 The ob_get_contents function is mainly used to obtain the cached content and return it as a string. Note that this function must be called before the ob_end_clean function; otherwise, the cache content cannot be obtained. 3The ob_end_clean function is mainly used to clear the content in the cache and disable the cache. If it succeeds, true is returned. If it fails, falsephp Output Control Function (output control) has many applications and will be expanded in the future. At this point, the method for generating static html pages using PHP to achieve static website is described. You can choose different static methods based on the actual situation and requirements.