0

我如何在Slim 3 路线中拥有 or-option ?

例如,这是我目前所做的:

// Home page.
$app->get('/', function (Request $request, Response $response, array $args) {
    // Get the application settings.
    $settings = $this->get('settings');

    // Check if the home page class is provided.
    ... lots of codes
});

$app->get('/home', function (Request $request, Response $response, array $args) {
    // Get the application settings.
    $settings = $this->get('settings');

    // Check if the home page class is provided.
    ... lots of codes
});

而不是重复这些代码的块,我可以把它们变成一个像:

$app->get('/ or /home', function (Request $request, Response $response, array $args) {
...}
4

1 回答 1

1

可选段是您正在寻找的。

于 2016-04-07T09:16:00.607 回答