Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 17200 программистов и 1834 робота. Сейчас ищут 1664 программиста ...

Features

Вернуться к: Net_URL_Mapper

Net_URL_Mapper can handle different types of mapping:

In the following examples we assume that URLs are mapped to a desginated controller and an action. But the controller and action keys provided could be called anything and are not mandatory.

Static path parts

The following code snippet maps the URL /home:

<?php
require_once 'Net/URL/Mapper.php';

$m Net_URL_Mapper::getInstance();
$m->connect('home', array('controller' => 'index''action' => 'index'));
var_dump($m->match($_SERVER['REQUEST_URI']));
?>

Dynamic path parts

The following code snippet maps a URL such as /news/1, /news/2 to a designated controller and action.

<?php
require_once 'Net/URL/Mapper.php';

$m Net_URL_Mapper::getInstance();
$m->connect('news/:id', array('controller' => 'news''action' => 'read'));
var_dump($m->match($_SERVER['REQUEST_URI']));
?>

Wildcard path parts

The following code snippet maps all URLs with /content to a controller called content and an action called display. Optionally, we'll determine the section on the page using a wildcard. The default for section is #toc (Table Of Contents).

<?php
require_once 'Net/URL/Mapper.php';

$m Net_URL_Mapper::getInstance();

$path     'content/*(section)';
$defaults = array(
    
'controller' => 'content',
    
'action'     => 'display',
    
'section'    => '#toc',
);

$m->connect($path$defaults);
var_dump($m->match($_SERVER['REQUEST_URI']));
?>


Вернуться к: Net_URL_Mapper

© 2024 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware