Welcome Guest, Not a member yet? Register   Sign In
Route passing $1 into the controller function instead of the value
#6

(This post was last modified: 05-22-2025, 11:35 PM by davis.lasis.)

Routes are most flexible thing i have ever used

PHP 8.3
CI 4.6.0

PHP Code:
$routes->get('{locale}/LoadEvents/(:any)', [FrontendController::class, 'LoadEvents/$1']);
$routes->get('{locale}/LoadEvents2/(:any)', [FrontendController::class, 'LoadEvents2']); 




PHP Code:
public function LoadEvents($id_1$id_2): string
    
{
        d($id_1);
        dd($id_2);
    }

    public function LoadEvents2(...$params): string
    
{
        dd($params);
    




1. www.domain.com/en/LoadEvents/123/987

PHP Code:
$id_1 string (3"123" 
PHP Code:
$id_2 string (3"987" 


2. www.domain.com/en/LoadEvents2/123/987/456/beekeeper/mnt-top

PHP Code:
$params array (5)
=> string (3"123"
=> string (3"987"
=> string (3"456"
=> string (9"beekeeper"
=> string (7"mnt-top" 

(05-22-2025, 10:41 PM)InsiteFX Wrote:
PHP Code:
$routes->get("Entry/(:any)",'Home::Entry/$1');
$routes->get("LoadEvents/(:any)",'Home::Load_Events/$l/$2'); <-- looks like an l not a 1 

Correct, that was small L, not integer 1
Reply


Messages In This Thread
RE: Route passing $1 into the controller function instead of the value - by davis.lasis - 05-22-2025, 11:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB