php - CodeIgniter 4 Routing - $ sign is not accepted in placeholder

one text

Solution:

It works without dollar signs because you're in effect just always passing the integers 1 and 2 into the Controller method, regardless of what's regex'd with the placeholders.

I think your problem is that http://localhost/sample/1/1 doesn't match the route /sample/(:any)/(:any), it matches /sample/(:any). The (:any) placeholder will literally glom onto anything, even multiple segments.

So defining a route as .../(:any)/(:any) is semantically pointless because the first (:any) is going to catch everything, leaving the second (:any) placeholder completely useless. As you've defined it now, the entire URI beyond sample/ is being passed into $1 via the first placeholder. You will never have a value to fill $2 with.

It appears to me that you really want to be limiting this placeholder to (:segment), not (:any).

Source