The php article content is paginated and the corresponding htm static file instance is generated-PHP source code

Source: Internet
Author: User
Ec (2); $ tmpBody & quot; fjka; fjsa; {page}: generate batch file splitting and add paging code & quot; & nbsp; & nbsp; $ tmpUrlwww.111cn.net; & nbsp; $ tmpUrlarrayexplode (., $ url) script ec (2); script

$ TmpBody = "fjka; fjsa; {page}: generate multiple files and add paging code ";

$ TmpUrl = 'www .111cn.net ';
$ TmpUrlarray = explode ('.', $ url );

$ TmpArray = explode ('{page}', $ tmpBody );
$ Total = count ($ tmpArray );

If ($ total> 1)
{
$ TmpStr = '';
For ($ I = 0; $ I <$ total; $ I ++) // traverses all pages
{
If ($ I = 0)
{
$ Str. = "'. ($ I + 1 ).'';
}
Else
{
$ Str. = "'. ($ I + 1 ).'';
}
}
// Generate files in batches and add paging code

$ Str ='

'. $ Str .'

';
For ($ j = 0; $ j <$ total; $ j ++)
{

If ($ j = 0)
{
$ Fname should contain rsw.'id'{.'.htm ';
}
Else
{
$ Fname should contain rsw.'id'}.'_'.w.j.'.htm ';
}
$ TempMu = str_replace ('{htmlContent}', $ tmpArray [$ j]. $ str, $ tempLate );
MakeHtml ($ tempMu, $ filePath, $ fname); // The code for creating a file is not described in this function.
}
$ Mupage = 1;

}

$ TempLate = str_replace ('{htmlContent}', $ tmpBody, $ tempLate); // common articles are retrieved by {page} and saved to an array to generate a paging address, then, the htm page is generated based on the content of the explode array. The source www.111cn.net is reproduced in the original tutorial on this site.
$ Total = 0;
$ Str = '';
$ I = 0;
$ J = 0;
/*
The origin of the Code is the id_page number, such as 100_1.htm,100_2.htm.
*/
?>

Related Article

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.