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

(12-14-2023, 03:47 AM)bgeneto Wrote:
Quote:With regular expressions, you can also catch a segment containing a forward slash (/), which would usually represent the delimiter between multiple segments.

For example, if a user accesses a password protected area of your web application and you wish to be able to redirect them back to the same page after they log in, you may find this example useful:

PHP Code:


But that's not the case, unless you rely on variable-length argument lists, i.e., multiple arguments. 

I have re-read the user guide and this description and the current behavior still do not match.
It is natural that the string that matches (.+) would be the one param $1.

If we define a route like this:
PHP Code:

and navigate to the URI products/shirts/123/456, the controller method parameters would be like:
$params array (3)
    ⇄0 => string (6) "shirts"
    ⇄1 => string (6) "id_123"
    ⇄2 => string (3) "456"

It seems to me that the current behavior should be changed.

Messages In This Thread
RE: How to setup a single route with optional argument - by kenjis - 12-14-2023, 04:47 PM

Theme © iAndrew 2016 - Forum software by © MyBB