Home >Backend Development >PHP Tutorial >PHP 长稿子分页 手动插入分页标签

PHP 长稿子分页 手动插入分页标签

WBOY
WBOYOriginal
2016-06-13 11:14:57892browse

PHP 长文章分页 手动插入分页标签

<?php $contents = $rs['content'];			function conpage($contents) {  			$pagesss='#page#';  //设定分页标签  			$a=strpos($contents,$pagesss);  			if($a){  			$con=explode($pagesss,$contents);  			$cons=count($con);   			@$p = ceil($_GET['p']);  			if(!$p||$p<0) $p=1;  			$url=$_SERVER["REQUEST_URI"];  			$parse_url=parse_url($url);  			$url_query=$parse_url["query"];  			if($url_query){  			$url_query=ereg_replace("(^|&)p=$p","",$url_query);  			$url=str_replace($parse_url["query"],$url_query,$url);  			if($url_query) $url.="&p"; else $url.="p";  			}else {  			$url.="?p";  			}  			if($cons<=1) return false;//只有一页时不显示分页  			$pagenav="<div class=\"lyztpage\">";  			for($i=1;$i'.$p.'';  				}else{  					$pagenav.="<a href="%24url=%24i">$i</a>";  				}  			}  			$pagenav.="";  			return $con[$p-1].$pagenav;  			}else{  			return $contents;  			}  		}  		 		echo conpage($contents);		?>

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