简体   繁体   中英

pass named arguments from a route to a controller

Given the following Controller:

class Page { public function about($section){ switch($section){} } }

How can I pass the a value to Page->about() directly from $f3->route ?

Fat-Free will populate two parameters to each routing handler. So when you got this route: $f3->route('GET /about/@section','\\Page->about'); it will call your function with 1st parameter being the framework instance and 2nd is an array of all routing arguments.

class Page { 
  public function about($f3, $args){
    switch($args['section']){} 
  } 
}

See http://fatfreeframework.com/routing-engine#RoutesandTokens for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM