php对文本文件进行分页功能简单实现
程序员文章站
2022-06-16 16:23:16
...
php对文本文件进行分页功能简单实现
Paging "; } if(ord(substr($str, $i, 1))>0xa0){ $tmp_str .= substr($str, $i, 2); $i++; }else{ $tmp_str .= substr($str, $i, 1); } } return $tmp_str;}// 传参处理if(isset($_GET['page'])){ $page = $_GET['page'];}else{ $page = 1;}$counter = file_get_contents("example.txt");$length = strlen($counter);$page_count = ceil($length/400);$pre_str = m_substr($counter, 0, ($page-1)*400);$now_str = m_substr($counter, 0, $page*400);echo substr($now_str, strlen($pre_str), strlen($now_str)-strlen($pre_str));echo "
";echo "当前页".$page."/".$page_count;echo "Index";if($page>1){ echo "Pre";}if($pageNext";}echo "End";?>