Php static page generation method (three functions)

Source: Internet
Author: User
Tags php write
Php static page generation method (three functions)

  1. /**

  2. Create directory
  3. */
  4. Function makedir ($ mudir)
  5. {
  6. $ File = "./$ mudir ";
  7. @ Mkdir ($ file, 0777 );
  8. }

  9. /**

  10. First, create the path of the child Touch Board file.
  11. */
  12. Function writemod ($ filemodname)
  13. {
  14. $ Fp = fopen ("showmod.shtml", "r ");
  15. $ Str = fread ($ fp, filesize ("showmod.shtml "));
  16. Fclose ($ fp );
  17. $ Fp = fopen ($ filemodname, "w ");
  18. Fwrite ($ fp, $ str );
  19. Fclose ($ fp );
  20. }

  21. /**

  22. Update the respective sub-board file // $ modfile is the sub-board name
  23. */
  24. Function writeweb ($ content, $ web, $ modfile)
  25. {
  26. $ Fp = fopen ($ modfile, "r ");
  27. $ Str = fread ($ fp, filesize ($ modfile ));
  28. $ Str = str_replace ($ content, $ web, $ str );
  29. Fclose ($ fp );
  30. $ Fp = fopen ($ modfile, "w ");
  31. Fwrite ($ fp, $ str );
  32. Fclose ($ fp );
  33. }
  34. USD m = "00000 ";
  35. Makedir ($ m );
  36. $ Ff = $ m. "/0001.shtml ";
  37. If (! File_exists ($ ff ))
  38. {
  39. Writemod ($ ff );
  40. }
  41. Else
  42. {
  43. Echo "already exists ";
  44. }
  45. $ D = "{content6}"; // Updated content
  46. $ Dd = ""; // the content to be updated
  47. @ Writeweb ($ d, $ dd, $ ff );
  48. ?>

Articles you may be interested in: three methods for generating static pages in php and code details: generating static page functions in php (php2html) for example, php generates html static pages, refer to a class written by php to generate html static pages for all the content in the database. php static page generation detailed tutorial apache cannot access pseudo static page solution php write about static page crawling record Code smarty generate static page method PHP generate static page solution: apache cannot access pseudo-static pages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.