<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## 路由回調 Each routing method described above accepts a callback routine as its final argument. This argument can be any PHP callable, and by default it accepts three arguments. > 上面描述的每個路由方法都接受一個回調例程作為它的最后一個參數。這個參數可以是任何PHP可調用的,默認情況下它接受三個參數。 * `Request`The first argument is a`Psr\Http\Message\ServerRequestInterface`object that represents the current HTTP request. * `Response`The second argument is a`Psr\Http\Message\ResponseInterface`object that represents the current HTTP response. * `Arguments`The third argument is an associative array that contains values for the current route’s named placeholders. > `Request`第一個參數是一個代表當前Http請求的`Psr\Http\Message\ServerRequestInterface`對象。 > > `Response`第二個參數是一個代表當前Http響應的`Psr\Http\Message\ResponseInterface`對象。 > > `Arguments`第三個參數是一個關聯數組,它包含當前路由的命名占位符的值。 ### 向響應寫入內容 There are two ways you can write content to the HTTP response. First, you can simply `echo()` content from the route callback. This content will be appended to the current HTTP response object. Second, you can return a `Psr\Http\Message\ResponseInterface` object. 有兩種方法可以將內容寫入HTTP響應。首先,您可以簡單地從路由回調`echo()`內容。此內容將附加到當前HTTP響應對象。其次,您可以返回一個`Psr\Http\Message\ResponseInterface`對象。 ### Closure binding閉包綁定 If you use a [dependency container](http://www.slimframework.com/docs/v4/concepts/di.html) and a `Closure`instance as the route callback, the closure’s state is bound to the `Container` instance. This means you will have access to the DI container instance `inside` of the Closure via the `$this` keyword: > 如果使用`依賴容器`和`閉包`實例作為路由回調,則閉包的狀態綁定到`容器`實例。這意味著你可以通過`$This`關鍵字訪問閉包內部的DI容器實例: ~~~php $app->get('/hello/{name}', function ($request, $response, $args) { // Use app HTTP cookie service $this->get('cookies')->set('name', [ 'value' => $args['name'], 'expires' => '7 days' ]); }); ~~~ **Heads Up!** Slim does not support`static`closures. > **提醒!** > Slim不支持`靜態`閉包。 ## Redirect helper重定向的助手 You can add a route that redirects `GET` HTTP requests to a different URL with the Slim application’s `redirect()` method. It accepts three arguments: 1. The route pattern (with optional named placeholders) to redirect `from` 2. The location to redirect `to` , which may be a `string` or a [Psr\\Http\\Message\\UriInterface](https://www.php-fig.org/psr/psr-7/#35-psrhttpmessageuriinterface) 3. The HTTP status code to use (optional; `302` if unset) > 您可以使用Slim應用程序的`redirect()`方法添加一個將 `GET`HTTP請求重定向到另一個URL的路由。它接受三個參數: > 1. 路由模式(帶有可選的命名占位符)來重定向 `from` > 2. 重定向到的位置,可以是一個 `string`或一個 [Psr\\Http\\Message\\UriInterface](https://www.php-fig.org/psr/psr-7/#35-psrhttpmessageuriinterface) > 3.要使用的HTTP狀態碼(可選;如果未設置的`302`) ~~~php $app->redirect('/books', '/library', 301); ~~~ `redirect()` routes respond with the status code requested and a `Location` header set to the second argument. > `redirect()`路由使用請求的狀態碼和設置到第二個參數的`Location`報頭來響應。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看