CodeIgniter Routing

$routes->http_method("route_name/placeholders", "ControllerName::method/segment_number"

Placeholders

(:any)

will match all the characters

(:num)

will match any integer

(:alpha)

will match any string of alphabetic characters

(:alphanum)

will match any string of alphabet characters, integers, or combination of two.

 Examples

$routes->get("/users", "UserController:: usersList");
$routes->post("/register", "UserController::register_user");

Get User by id

$routes->get("/users/(:num)", "UserController::users/$1");

Get user and age at controller sub folder

$routes->get("/admin_register/(:any)/(:num)", "Admin\AdminController::admin_register/$1/$2");

 

© 2016 - 2022, All Rights are Reserved.