PHP Classes

File: documentor/method_not_acceptable.php

Recommend this page to a friend!
  Classes of Mark Rolich   PHP URL Router Class   documentor/method_not_acceptable.php   Download  
File: documentor/method_not_acceptable.php
Role: Example script
Content type: text/plain
Description: Documention generator files
Class: PHP URL Router Class
Match URLs with routes for controllers and actions
Author: By
Last change: Update of documentor/method_not_acceptable.php
Date: 4 months ago
Size: 422 bytes
 

Contents

Class file image Download
<?php
use Bike\Router;
use
Bike\RouterException;

try {
   
$router = new Router();

   
$router->add('controller-only',
        array(
           
'method' => 'GET, POST',
           
'route' => '/controller'
       
)
    );

   
$result = $router->match('PUT', '/news');
} catch (
RouterException $e) {
    if (
$e->getCode() === 2) {
       
$result = $e->getMessage();
    }
}

// output: 'Method PUT is not allowed'
?>