本文介紹了錯誤“試圖訪問類型為 null 的值的數組偏移量"Laravel 5.8.26 PHP 7.4.2的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我使用以下功能從管理面板插入/創建新用戶:
I use below function for insert/create new user from admin panel:
public function store(Request $request)
{
$this->validate($request, [
'name' => 'required',
'email' => 'required|email|unique:users,email',
'password' => 'required|same:confirm-password'
]);
$input = $request->all();
$input['password'] = Hash::make($input['password']);
User::create($input);
return redirect()->route('admin.pages.users.index')
->with('success','User created successfully');
}
當我提交時出現如下錯誤:-
when I submit I get error as below :-
嘗試訪問類型為 null 的值的數組偏移
Trying to access array offset on value of type null
我發現了我的問題.我的問題是電子郵件驗證規則.當我刪除電子郵件驗證插入數據是真的.
I found my problem. my problem is email validation rule. when i remove email validation insert data is true.
我該如何解決這個錯誤!
How do can i fix this error !
推薦答案
將 Composer.json 中的 PHP 版本更改為 7.4.1 并運行
Change Your Php version in Composer.json to 7.4.1 and run
composer update
這對我有用
這篇關于錯誤“試圖訪問類型為 null 的值的數組偏移量"Laravel 5.8.26 PHP 7.4.2的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!