Advertisement
Sungper

Php Route A jour

Jun 24th, 2019
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2. class  Router{
  3.    
  4.     static $routes = array();
  5.     public static function add($link, $url, $as = null){
  6.         self::$routes[] = [
  7.             'link'  =>  $link,
  8.             'url'   =>  $url,
  9.             'as'    =>  $as
  10.                 ];
  11.     }
  12.     public static function getArray(){
  13.         return self::$routes;
  14.     }
  15.     public static function name($input){
  16.         foreach (self::$routes as $r){
  17.             if($input == $r['as'] || $input == $r['link']){
  18.                 echo $r['link'];
  19.                 break;
  20.             }
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement