public function foo(Request $request) { $foo = $request->get('a'); $foo = $request->input('a'); }
這裡用get和input有差別嘛?
不一樣。
大概看了下input取得到陣列後簡單做了下取出操作,get有一套更完善的取出機制,也有很多拋異常操作。
具體LZ可以去翻翻原始碼看看:input方法在:/vendor/laravel/framework/src/Illuminate/Http/Request.php/vendor/laravel/framework/src/Illuminate/Http/Request.phpget方法在:/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.phpget方法在:/vendor /symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php
/vendor/laravel/framework/src/Illuminate/Http/Request.php
/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php
/vendor /symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php
PS,我手上目前是4.2
不一樣。
大概看了下input取得到陣列後簡單做了下取出操作,
get有一套更完善的取出機制,也有很多拋異常操作。
具體LZ可以去翻翻原始碼看看:
input方法在:
/vendor/laravel/framework/src/Illuminate/Http/Request.php
/vendor/laravel/framework/src/Illuminate/Http/Request.php
get方法在:
/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php
get方法在:/vendor /symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php
PS,我手上目前是4.2