Home"; //Previous page link $pdiv .= "
  • Home
  • "; //Previous page link $pdiv .= "
  • Home >Backend Development >PHP Tutorial >http://www.hunanzhibo.com/ PHP article content is paginated and the corresponding htm static page code is generated

    http://www.hunanzhibo.com/ PHP article content is paginated and the corresponding htm static page code is generated

    WBOY
    WBOYOriginal
    2016-07-29 08:43:001165browse

    Copy the code The code is as follows:


    $url='test.php?1=1';
    $c style="text-decoration:none;">Homepage

  • ";
    //Previous page link
    $pdiv .= "
  • Previous page
  • ";
    //Display paginated list
    $color = '';
    for($i = 1; $ i<=$total; $i++)
    {
    if($i == $nowpage)
    {
    $color= "color:#ff0000;";
    }
    else
    {
    $color = '';
    }
    $pdiv .= "
  • < span style="{$color}">{$i}
  • ";
    }
    //Next page link
    $pdiv .= "
  • Next page//Last page link
    $pdiv .= "
  • Last page
  • ";
    $pdiv .= '';
    //Output content
    echo $arr[$nowpage-1];
    //If no paging, the paging list will not be displayed
    if( $total <=1) $pdiv = '';
    //Output the paging list
    echo $pdiv;
    ?>


    The following is the relevant statically generated page , although the code is incorrect, the idea is okay.

    Copy the code The code is as follows:


    $tmpBody = "fjka;fjsa;{page} is batch generated into files and added with paging code";
    $tmpUrl = 'www.jb51.net ';
    $tmpUrlarray = explode('.',$tmpUrl);
    $tmpArray = explode('{page}',$tmpBody);
    $total = count($tmpArray);
    $id="2";
    if( $total >1 )
    {
    $tmpStr = '';
    for( $i=0;$i<$total;$i++ ) //Traverse all pages
    {
    if( $i==0 )
    {
    $str .=''.($i+1).' ';
    }
    else
    {
    $str .=''.($i+1).' ';
    }
    }
    //Batch generate files and add paging code
    $str = '

    '.$str.'
    ';
    for( $j=0 ;$j<$total;$j++ )
    {
    if( $j==0 )
    {
    $fname =$id.'.htm';
    }
    else
    {
    $fname =$id.'_ '.$j.'.htm';
    }
    $tempMu = str_replace('{htmlContent}',$tmpArray[$j].$str,$tempLate);
    makeHtml($tempMu,$filePath,$fname) ; //This function will not be explained, a code to create a file
    }
    $mupage =1;
    }
    $tempLate = str_replace('{htmlContent}',$tmpBody,$tempLate); //Ordinary articles start with { page}Paging is taken out and saved to an array to regenerate the paging address, and then the htm page is generated from the contents of the array divided according to explode
    $total=0;
    $str='';
    $i=0;
    $j=0 ;
    /*
    The principle of generating this code is that the id_page number is in the form of 100_1.htm, 100_2.htm. First, put
    */
    function makeHtml($tempMu,$filePath,$fname){
    $fp = fopen($filePath.$filename, "w");
    fwrite($fp, $tempMu);
    fclose($fp);
    }
    ?>

    The above has introduced the paging of http://www.hunanzhibo.com/ PHP article content and generated the corresponding htm static page code, including the content of http://www.hunanzhibo.com/. I hope you are interested in PHP tutorials. Friends help.

    Statement:
    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
    Previous article:Location code input method: Analysis of source code application examples for converting Chinese characters to location codes in PHPNext article:Location code input method: Analysis of source code application examples for converting Chinese characters to location codes in PHP

    Related articles

    See more