How to setup a single route with optional argument |
(12-08-2023, 05:25 PM)kenjis Wrote: > the last parameter is optional (the class method has a default value in its second parameter) That's unfortunate. We frequently run across routes that require this last optinal argument. As far as I can recall, this was a feature of the CI v3. Thanks for your detailed reply! It works indeed... But I insist that, according to the docs (at least to my understanding of the documentation), the (:any) placeholder should "match all characters from that point to the end of the URI. This may include multiple URI segments." And this is not the case, as you can see in this minimal example: PHP Code: $routes->get('/anyplaceholder/(:num)/(:any)', 'Test::placeholderAny/$1/$2'); The same holds true for regex placeholders, from the docs: "With regular expressions, you can also catch a segment containing a forward slash (/), which would usually represent the delimiter between multiple segments." PHP Code: /** PHP Code: $routes->get('/regexplaceholder/(.+)', 'Test::regexPlaceholder/$1'); But also in this case only the value "path" will be outputed. At least from me (using CI v4.4.3). Is this supposed to be the right behaviour? Best regards! |
Welcome Guest, Not a member yet? Register Sign In |