简体   繁体   中英

Why request() helper function returns null

According episode 19 Laravel 5.4. from Scratch (time 4:53) from laracasts.com video, code request(['name', 'email', 'password']) should return array containing name, email and password from user registration form.

But in my case it returns null .

I'm sure, form is ok because request()->only(['name', 'email', 'password']) works. It returns Array( [name] => awesomename [email] => email@email.com [password] => asdfadsf) properly.

What could be wrong?

Look at the documentation for the helper:

https://laravel.com/docs/5.4/helpers#method-request

It only gets the current request or obtains an input item. It does not accept an array as an argument.

$request = request();

$value = request('key', $default = null)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM