Home >Backend Development >PHP Tutorial >Detailed explanation of using thinkphp's own method to generate static html files_PHP tutorial
thinkphp itself comes with an effective method of generating static pages. (This method is explained in the tp2.0 manual, but not in the 3.0 manual, but the 3.0 method still exists.)
$this->buildHtml('static file', 'static path', 'template file');
Let me explain the parameters a little bit. Some friends asked me about this parameter and how to use it.
Parameter 1: Static file refers to the generated static file name. The complete file saving path is: static path/static file. For example, the static file is set to a/index. Then the saved path is the project
project path/Html/a/index.html (the default static path is in the Html folder of the project path, you can create it yourself)
Parameter 2: Static path , the default path has been explained above. In 3.0, parameters can be added to the entry file to change the static path.
define('HTML_PATH', './'); (define the static path as the website root directory)
Parameter 3: Template file . I feel that the official description is incorrect. To be precise, it should be the target module, which is the module that needs to generate static files. Format: module name: operation. For example, if you want to generate the a method under Index as a static file, that is Index:a. If empty, the static file of the current operation will be generated by default.
Example: