Home > Backend Development > PHP Tutorial > Simple example of generating static files with PHP

Simple example of generating static files with PHP

WBOY
Release: 2016-07-25 08:55:02
Original
1034 people have browsed it
  1. /**
  2. * @desc Used when generating static files
  3. * @todo htmlcache
  4. * @param $root string html file storage path
  5. * @param $rule string html file naming rules
  6. * @param $url string ** that needs to generate HTML files Page address
  7. * @return boole true/false
  8. */
  9. public function setHtmlCache($root,$rule,$url){
  10. //Detect whether static files have been generated
  11. if (file_exists($root. $rule.'.html')){//Static files already exist
  12. @unlink($root.$rule.'.html');//Delete static files
  13. return file_put_contents($root.$rule.'.html ', file_get_contents($url));//Regenerate
  14. }else{//If there is no static file, generate it directly
  15. return file_put_contents($root.$rule.'.html', file_get_contents($url));
  16. }
  17. }
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template