Advertisement
daixso

PHP Paging System

Apr 25th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <?php
  2.  
  3. class Page {
  4.     private $page; //global page variable
  5.  
  6.     //constructor recieves requested page from
  7.     //the index via get ?page=
  8.     public function __construct($page_) {
  9.       $this->page = $page_; //assign passed page to global variable
  10.       $this->pageExists($this->page); //pass page for verification
  11.     }
  12.  
  13.     //check if page exists and if it does
  14.     //pull the content from it
  15.     private function pageExists() {
  16.       if(file_exists("./pages/$this->page.php")) {
  17.         //file exists and can be loaded
  18.         echo file_get_contents("./pages/$this->page.php");
  19.       } else {
  20.         //page does not exist
  21.         //TODO: Create a 404 page to redirect to
  22.         echo "Warning: Page $this->page was not found!";
  23.       }
  24.     }
  25. }
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement