$url='test.php?1=1 ';
$contents="fjka;fjsa;#page#Batch generate files into files and add paging code";
$ptext ='#page#';
ContentsPages($url,$contents, $ptext)
/**
* Function name: ContentsPages
* Function: Article content paging
* Parameters: $url article content page URL type string, $contents article content page content type string, $ptext paging identification type string
* Author: Qiye
* QQ:64438136 linus.php@gmail.com MSN:zhijian@live.com
*/
//Array of articles
$arr = explode($ptext,$contents);
//Array length & total number of pages
$total = count($arr);
//Current page
$nowpage = $_GET['pages']?$_GET['pages']:1;
//Previous page
$prepage = $nowpage==1?1:$nowpage-1;
//Next page
$nextpage = $nowpage>$total-1?$total:$nowpage+1;
// Last page
$lastpage = $total;
$pdiv = '
';
$pdiv .= "{$nowpage}/Total {$total} pages ";
//Homepage link
$pdiv .= "
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 .= "
{$i}";
}
//Next page link
$pdiv .= "
Next page";
//Last page link
$pdiv .= "
Last page ";
$pdiv .= '
';
//Output content
echo $arr[$nowpage-1];
//Do not display the paginated list if it is not paginated
if( $ total <=1) $pdiv = '';
//Output paging list
echo $pdiv;
?>
The following is the relevant statically generated page, although The code is incorrect but the idea is fine.