Welcome Guest, Not a member yet? Register   Sign In
How to setup a single route with optional argument
#1

Hi! 
I'm trying to setup a single route that allows a second optional argument like this:
Code:
$routes->get('user_details/(:num)/(:any)?', 'MyClass::userDetails/$1/$2');

It works with two parameters/args. The problem is that I've got a 404 if I use it with a single argument. 
Additionally, if the second parameter is a string containing a forward slash (/), the routing mechnism considers only the characters before the slash. 
I thought that was the case only with (Confusedegment) and not with (:any). Is this a bug? 
Any suggestions on how do I accomplish what I want, meaning: 
  • two parameters
  • the last parameter is optional (the class method has a default value in its second parameter)
  • the last parameter can contain a forward slash.
Any help is welcome. 
Regards.
Reply


Messages In This Thread
How to setup a single route with optional argument - by bgeneto - 12-08-2023, 03:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB