PHP 간단한 페이지 매김 클래스를 작성하고 싶습니다. 여기 내 코드는 다음과 같습니다.PHP 클래스 변수를 에코 할 수 없습니다
<?php
class Pagination {
public $rowsPerPage;
public $currentPage;
public $totalPages;
public $totalRows;
public $firstElement;
public $lastElement;
public function paginate()
{
if(isset($_GET['page'])){
$this->currentPage = $_GET['page'];
}
$this->totalPages = $this->totalRows/$this->rowsPerPage ;
return $this->totalPages;
$this->firstElement = $this->currentPage-1)*$this->rowsPerPage+1;
return $this->firstElement;
}
}
$totalRecords = 55;
$paginator = new Pagination();
$paginator->totalRows = $totalRecords;
$paginator->rowsPerPage = 5;
$paginator->paginate();
echo $paginator->totalPages;
echo $paginator->firstElement;
?>
echo $ paginator-> totalPages; 하지만 $ paginator-> firstElement는 아닙니다. 내가 뭘 잘못 했니? 감사합니다.
I가도 _construct 기능 공개 _construct 함수() { \t \t \t $ this-> rowsPerPage = 5; $ this-> currentPage = 1; $ this-> totalPages = 0; \t \t \t $ this-> totalRows = 40; \t \t \t $ this-> firstElement = 0; \t \t \t $ this-> lastElement = 0; \t \t \t – user2359958
$ this-> firstElement에 구문 오류가 있지만 닫는 괄호는 있지만 여는 것은 아닙니다. –
[오류보고]를 켜십시오 (http://php.net/error+reporting). –