CodeIgniter Forums
Route error when the value is greater than 9 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Route error when the value is greater than 9 (/showthread.php?tid=78448)



Route error when the value is greater than 9 - zoom360 - 01-20-2021

My configuration:

Code:
$routes->group('members', ['namespace' => 'App\Controllers'], function ($routes) {
    $routes->get('/', 'Members::index');
    $routes->add('(:any).(:num)/aaa', 'Members::aaa/$1.$2');
});
My link: https://domain.com/members/abcdef.13/aaa
When "(:num)" is less than 10, it's true.
When "(:num)" is greater than or equal to 10, it's false.


RE: Route error when the value is greater than 9 - tgix - 01-20-2021

I'm on my phone commuting so I'm just guessing: I think the route function should be defined as Members::aaa/$1/$2 so you pass the (:num) segments as two arguments properly.


RE: Route error when the value is greater than 9 - zoom360 - 01-20-2021

(01-20-2021, 11:40 PM)tgix Wrote: I'm on my phone commuting so I'm just guessing: I think the route function should be defined as Members::aaa/$1/$2 so you pass the (:num) segments as two arguments properly.
This is function in Controller:

Code:
public function aaa($slug = '')
{
    /* I will get slug = (:any).(:num)
}
I'll get value (:any).(:num).


RE: Route error when the value is greater than 9 - iRedds - 01-21-2021

Add a backslash before the dot between (:any) and (:num)
(:any)\.(:num)


RE: Route error when the value is greater than 9 - zoom360 - 01-21-2021

(01-21-2021, 12:47 AM)iRedds Wrote: Add a backslash before the dot between (:any) and (:num)
(:any)\.(:num)
Thanks @iRedds !
It's work!