PHP Classes

File: routes.php

Recommend this page to a friend!
  Packages of António Lourenço   Lou Router   routes.php   Download  
File: routes.php
Role: Example script
Content type: text/plain
Description: Route configuration example
Class: Lou Router
Route HTTP requests using callback functions
Author: By
Last change:
Date: 1 year ago
Size: 569 bytes
 

 

Contents

Class file image Download
<?php
    // add the Router class
    require_once 'Router.php';

    // Create a Router instance
    $router = new Router();

    // Add routes
    $router->addRoute('/', function() {
        global $content;
        $content = "This page is index!";
        require_once 'index.php';
    });
    
    $router->addRoute('home', function() {
        global $content;
        require_once 'home.php';
    });

    $router->addRoute('about', function() {
        global $content;
        require_once 'about.php';
    });

    $router->addRoute('contact', function() {
        global $content;
        require_once 'contact.php';
    });