Route Optional Parameter |
Hello
I am trying to add optional parameter to my and seem not getting it. The documentation did not mention anything about it. Some thing like this PHP Code: $routes->get('user/(optional)', "Home::user"); Please any idea Thanks PHP Code: $routes->get('user/(:any)', "Home::user/$1"); There are other things that you can do also. A route with (:any) should be the last route in the route list. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Here are the chapter you where looking for: https://codeigniter.com/user_guide/incom...uting.html
(04-28-2020, 08:04 AM)InsiteFX Wrote: Thank you for your reply I have tried all this, it's not working, when i go the "mysite/user/anything_here" it works but when I go to "mysite/user" it show 404 error (Can't find a route for 'user') Any other option pls
(04-28-2020, 09:51 AM)jreklund Wrote: Here are the chapter you where looking for: https://codeigniter.com/user_guide/incom...uting.html Thank you, I have gone through the documentation, it has no information about optional parameter
You need to route user as well.
PHP Code: $routes->get('user/(:num)', "Home::user/$1");
|
Welcome Guest, Not a member yet? Register Sign In |