Web development source code: PHP static page generation class _ PHP Tutorial

Source: Internet
Author: User
Web development source code: PHP class for generating static pages. Classhtml {var $ dir; dirforthehtmls (without) var $ rootdir; rootofhtmlfiles (without): htmlvar $ name; html file storage path var $ dirname; specified folder name class html
{
Var $ dir; // dir for the htmls (/)
Var $ rootdir; // root of html files (without/): html
Var $ name; // html file storage path
Var $ dirname; // The specified folder name.
Var $ url; // The Source webpage address for retrieving html file information
Var $ time; // time When html file information is added
Var $ dirtype; // Directory storage method: year, month ,,,,
Var $ nametype; // name of the html file: name

Function html ($ nametype = 'name', $ dirtype = 'year', $ rootdir = 'html ')


Function setvar ($ nametype = 'name', $ dirtype = 'year', $ rootdir = 'HTML ')


Function createdir ($ dir = '')
{
$ This-> dir = $ dir? $ Dir: $ this-> dir;

If (! Is_dir ($ this-> dir ))
{
$ Temp = explode ('/', $ this-> dir );
$ Cur_dir = '';
For ($ I = 0; $ I {
$ Cur_dir. = $ temp [$ I]. '/';
If (! Is_dir ($ cur_dir ))

}
}
}

Function getdir ($ dirname = '', $ time = 0)
{
$ This-> time = $ time? $ Time: $ this-> time;
$ This-> dirname = $ dirname? $ Dirname: $ this-> dirname;

Switch ($ this-> dirtype)
{
Case 'name ':
If (empty ($ this-> dirname ))
$ This-> dir = $ this-> rootdir;
Else
$ This-> dir = $ this-> rootdir. '/'. $ this-> dirname;
Break;
Case 'year ':
$ This-> dir = $ this-> rootdir. '/'. date ("Y", $ this-> time );
Break;

Case 'month ':
$ This-> dir = $ this-> rootdir. '/'. date ("Y-m", $ this-> time );
Break;

Case 'day ':
$ This-> dir = $ this-> rootdir. '/'. date ("Y-m-d", $ this-> time );
Break;
}

$ This-> createdir ();

Http://www.bkjia.com/PHPjc/631963.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/631963.htmlTechArticleclass html {var $ dir; // dir for the htmls (without/) var $ rootdir; // root of html files (without/): html var $ name; // html file storage path var $ dirname; // The specified folder name...

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.