From the course: PHP: Object-Oriented Programming with Databases
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Define a pagination class - PHP Tutorial
From the course: PHP: Object-Oriented Programming with Databases
Define a pagination class
- [Narrator] In this movie, we will define a new class that can help us to keep track of our pagination variables and calculations. So let's create a new class. This is going to go inside our classes directory. Make a new file, and I'm going to call it pagination.class.php. It will need some php tags, and it's going to be a class definition for pagination. So inside this class, we want to keep track of the different properties. And we know that there are three main variables we want to keep track of. Public current page, public per page, and public total count. So the way that I think that we'll add those properties in here is when we create a new instance of the pagination, we can just pass those in while we're creating it and then it will set them. So let's define a construct method that'll do that for us. Public function__construct and then we'll pass in the page=1 and per page is going to default to 20 and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.