Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
linenumberstrue
<?php
Route::get('hello', function() {
    return 'Hello!';
});

...

Code Block
languagephp
linenumberstrue
<?php
Route::get('hello/world', function() {
    return 'Hello World';
});

...

Code Block
languagephp
linenumberstrue
<?php
Route::get('hello/world/{name}', function($name) {
    return 'Hello World ' . $name;
});

...

다음과 같이 라우팅이 정의되어 있을 경우 라라벨의 라우터는 두 가지 라우트중 파라미터가 있는 것을 사용하게 됩니다.

Code Block
<?php
Route::get('hello/world/', function($name) {
    return 'Hello World ' . $name;
});
Route::get('hello/world/{name}', function($name) {
    return 'Hello World ' . $name;
});

...

Code Block
languagephp
linenumberstrue
<?php
Route::get('hello/world/{name?}', function($name = null) {
    return 'Hello World ' . $name;
});

...

Code Block
languagephp
linenumberstrue
<?php
Route::get('hello/world/{name?}', function($name = 'lesstif') {
    return 'Hello World ' . $name;
});

...