Welcome Guest, Not a member yet? Register   Sign In
Route with optional parameter
#3

(This post was last modified: 07-18-2020, 02:14 AM by jreklund.)

You don't need to specify multiple (:any), you can just get away with two routes.

PHP Code:
$routes->get('logout/(:any)''Login::logout/$1');
$routes->get('logout''Login::logout'); 

public function 
logout($param1 null$param2 null$param3 null)
{
    
var_dump($param1$param2$param3); exit;
}

// or

public function logout(...$params)
{
    
var_dump($params); exit;


You can't however get away with just one routing rule. As (:any) can't be optional.
Reply


Messages In This Thread
Route with optional parameter - by Cyto5 - 07-17-2020, 10:52 AM
RE: Route with optional parameter - by tgix - 07-17-2020, 11:03 PM
RE: Route with optional parameter - by jreklund - 07-18-2020, 02:12 AM
RE: Route with optional parameter - by tgix - 07-18-2020, 02:57 AM
RE: Route with optional parameter - by MGatner - 07-22-2020, 02:03 PM
RE: Route with optional parameter - by edyahui - 11-16-2020, 06:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB