-
Notifications
You must be signed in to change notification settings - Fork 3
Error function
Andre Sieverding edited this page Jun 13, 2014
·
4 revisions
(EasyRouter >= 0.3.0)
EasyRouter\main::error( string $href [, int $params = null ] )$href = URI to an error document. (404, 500, etc.)
$params = Number of allowed parameters in the URI.
Returns FALSE on failure.
<?php
EasyRouter\main::prepare("{language}/{id}-{page}/{subpage}");
EasyRouter\main::execute();
EasyRouter\main::error("http://www.yourwebsite.com/404.html");
?>http://www.yourwebsite.com/en/21-customers/new will generate this:
$_GET['language'] = 'en'
$_GET['id'] = '21'
$_GET['page'] = 'customers'
$_GET['subpage'] = 'new'
http://www.yourwebsite.com/de/21-customers will generate this:
$_GET['language'] = 'de'
$_GET['id'] = '21'
$_GET['page'] = 'customers'
http://www.yourwebsite.com/en/21-customers/new/param1/param2 will ridirect you to your error document.
<?php
EasyRouter\main::prepare("{language}/{id}-{page}/{subpage}");
EasyRouter\main::execute();
EasyRouter\main::error(EasyRouter\main::get_active_path(true) . "404.html", 2);
?>http://www.yourwebsite.com/en/21-customers will generate this:
$_GET['language'] = 'en'
$_GET['id'] = '21'
$_GET['page'] = 'customers'
http://www.yourwebsite.com/de will generate this:
$_GET['language'] = 'de'
http://www.yourwebsite.com/en/21-customers/new will ridirect you to your error document.
This function also works with the start function!