Собственно вопрос, перехожу на php 7+ но проблема не выводит пагинацию.
Выдает ошибку: Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; pagination has a deprecated constructor in /classes/pagination.php on line 33
if( ! class_exists( 'pagination' ) )
{
class pagination
{
var $show = 5; // сколько показывать одновременно страниц
function pagination($total_rows, $rows_per_page, $page_num){
$this->total_rows = $total_rows;
$this->rows_per_page = $rows_per_page;
$this->page_num = $page_num;
}
function calculate_pages(){
$page_num = $this->page_num;
$arr = array();
$last_page = ceil($this->total_rows / $this->rows_per_page);
$page_num = (int) $page_num;
if ($page_num < 1){
$page_num = 1;
}elseif ($page_num > $last_page){
$page_num = $last_page;
}
$upto = ($page_num - 1) * $this->rows_per_page;
$arr['current'] = $page_num;
if ($page_num == 1){
$arr['previous'] = $page_num;
}else{
$arr['previous'] = $page_num - 1;
}
if ($page_num == $last_page){
$arr['next'] = $last_page;
}else{
$arr['next'] = $page_num + 1;
}
$arr['last'] = $last_page;
$arr['pages'] = $this->get_surrounding_pages($page_num, $last_page, $arr['next']);
return $arr;
}
function get_surrounding_pages($page_num, $last_page, $next){
$arr = array();
$show = $this->show;
if ($page_num == 1){
if ($next == $page_num){
return array(1);
}
for ($i = 0; $i < $show; $i++){
if ($i == $last_page){
break;
}
array_push($arr, $i + 1);
}
return $arr;
}
if ($page_num == $last_page){
$start = $last_page - $show;
if ($start < 1){
$start = 0;
}
for ($i = $start; $i < $last_page; $i++){
array_push($arr, $i + 1);
}
return $arr;
}
$start = $page_num - $show;
if ($start < 1){
$start = 0;
}
for ($i = $start; $i < $page_num; $i++){
array_push($arr, $i + 1);
}
for ($i = ($page_num + 1); $i < ($page_num + $show); $i++){
if ($i == ($last_page + 1)){
break;
}
array_push($arr, $i);
}
return $arr;
}
}
}
?>
Знаю что нужно делать как-то через конструктор, но я не понимаю как, кто подскажет?