Create directories as well as file writes, as required by friends can refer to below. Requirements Description: Generates a static HTML page of the previewed PHP page and stores it in the appropriate folder. 1. The preview information is the query database to upload the corresponding information to the view layer display. 2. Generate HTML for the PHP page
- $root _dir = $_server["Document_root"]; Get root directory
- $NowYear = Date ("Y"); Create a directory with a "year" level
- $dir _path = "$root _dir/abc/bcd/". $NowYear. " /". $edm [' Showtime ']."; /Get a directory based on the current year and the corresponding time
- $file _path = $dir _path. " /index.html "; File name is index.html
- mkdir ($dir _path,0777,true);//Create a file directory 777 is a permission, true indicates that a multilevel directory can be generated
- $EDM _templates = $sqlquery _get_data;//sql Get data
- $data = Array (///page requires some data
- ' Info ' = $info,
- ' Result ' = $edm _templates,
- );
- $this->load->vars (' info ', $data);
- $data = $this->load->view (URL, ", true); Get the data needed to generate HTML
- if (empty ($data)) Ajaxreturn ("," no Read permission or no query to the corresponding file!) ', 0);
- File_put_contents ($file _path, $data);//Generate file
- Ajaxreturn (', ' Build succeeded! ', 2);
Copy CodeThe previous idea was that the file_get_contents () function was to get the page information, but the page needed to be logged in. That is, the server requests the page, and then it is blocked on the landing page. The previous use of this function is then generated by the login page. In general, the creation of a directory is the MkDir function, the file is written with file_put_contents This function is more convenient. |