<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] Laravel請求組件用的是symfony/http-foundation組件 # 取值 ~~~ //use Illuminate\Http\Request; public function index(Request $request) //通過依賴注入 { //取值 $result=$request->input('name'); //如果沒有值,想給個默認值 $result=$request->input('sex','未知'); //如何判斷有沒有傳這個值呢? if ($request->has('name')) { echo $request->input('name'); //有就輸出 } else { echo '無參數'; //沒有就輸出這個 } //輸出全部 $res=$request->all(); } ~~~ # 判斷請求類型 ~~~ echo $request->method(); //判斷是不是post if ($request->isMethod('POST')) { echo 'yes'; } //判斷是不是ajax請求 $res=$request->ajax(); //是就true 不是為false //判斷是不是控制器下的某個方法 Route::get('/stu','StudentController@index'); $res=$request->is('student/*'); ~~~ # 其他常見用法 ~~~ Request::only(''); //只要請求參數里面的值 Request::except(''); //只要過濾請求參數里面的值 Request::url(); //輸出url,?后面不輸出 Request::fullurl(); //輸出完整url,?也輸出 ~~~ # Route 中的 Parameter Laravel 中獲取 route 中的 parameter 的方法: ~~~ //假設 route 是這樣的: $router->resource('posts.comments', PostCommentController::class); //獲取的方法: $postId = $request->posts; $commentId = $request->comments; ~~~ Lumen 中的 routeResolver 有點不太一樣,不能這樣: ~~~ $postId = $request->posts; ~~~ 也不能這樣: ~~~ $postId = $request->route('posts'); ~~~ 報錯:Call to a member function parameter() on array 所以正確的做法是自己解析:$request->route(),略坑。 有人寫了一個 helper 的方法: ~~~ if (!function_exists('route_parameter')) { /** * Get a given parameter from the route. * * @param $name * @param null $default * @return mixed */ function route_parameter($name, $default = null) { $routeInfo = app('request')->route(); return array_get($routeInfo[2], $name, $default); } } ~~~
                  <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>

                              哎呀哎呀视频在线观看