문제

I'm having a little bit of trouble getting a Laravel 4 route working - just couldn't get my head around it what I'm doing wrong.

My composer packages are up-to-date and I'm using the latest version of illuminate/app.

Here's a route which works fine:

GET /hello

Route::get('hello', function()
{
    return 'yey';
});

But I just can't get a second uri segment to pass as a param.

This didn't work:

GET /hello/1

Route::get('hello/(:num)', function($id)
{
    return 'yey ' . $id;
});

Or:

GET /hello/1

Route::get('hello/(:any)', function($id)
{
    return 'yey ' . $id;
});

Ultimately I want a controller to handle my stuff - but I just don't know what I'm doing wrong at the moment.

도움이 되었습니까?

해결책

Nearly. Really you want to be doing this:

Route::get('hello/{num}', function($id)
{
    return 'yey ' . $id;
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top