Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Page {
- private $page; //global page variable
- //constructor recieves requested page from
- //the index via get ?page=
- public function __construct($page_) {
- $this->page = $page_; //assign passed page to global variable
- $this->pageExists($this->page); //pass page for verification
- }
- //check if page exists and if it does
- //pull the content from it
- private function pageExists() {
- if(file_exists("./pages/$this->page.php")) {
- //file exists and can be loaded
- echo file_get_contents("./pages/$this->page.php");
- } else {
- //page does not exist
- //TODO: Create a 404 page to redirect to
- echo "Warning: Page $this->page was not found!";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement