isset 或空 Laravel 5.1 中的非法偏移类型

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31661100/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:03:35  来源:igfitidea点击:

illegal offset type in isset or empty Laravel 5.1

phpformslaravellaravel-5

提问by Chaudhry Waqas

I get this error
ErrorException in Arr.php line 232: Illegal offset type in isset or empty (View: C:\firstapp\resources\views\about\contact.blade.php)when I visit the /contact page and the contact page is


ErrorException in Arr.php line 232: Illegal offset type in isset or empty (View: C:\firstapp\resources\views\about\contact.blade.php)当我访问 /contact 页面时出现此错误,并且该联系页面是

@extends('layouts.master')
<h1>Contact Form</h1>

@foreach($errors->all() as $error)
    <li>
        {{$error}}
    </li>
@endforeach

{!! Form::open(['route'=>'contact_store','class'=>'form-control']) !!}

    <div class="form-group">
        {!! Form::label('name','Name :') !!}
        {!! Form::text('name',null,['class'=>'form-control']) !!}

    </div>

    <div class="form-group">
        {!! Form::label('email','Your E-mail Address') !!}
        {!! Form::text('email', null, ['class'=>'form-control']) !!}
    </div>

    <div class="form-group">
        {!! Form::label('message','Your Message') !!}
        {!! Form::textarea('message', null, ['class'=>'form-control']) !!}
    </div>

    <div class="form-group">
        {!! Form::input('Contact Me',['class'=>'btn btn-primary form-control']) !!}
    </div>

{!! Form::close() !!}

What am I doing wrong here? The main problem is that laravel is not even telling me the line number where the issue is. Here is the aboutController code

我在这里做错了什么?主要问题是 Laravel 甚至没有告诉我问题所在的行号。这是 aboutController 代码

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class AboutController extends Controller
{
    public function create()
    {
        return view('about.contact');
    }

    public function store()
    {
    }
}

采纳答案by Ray

Your last Form::inputmight be the problem, It's n ot correctly formatted for an input or if you;re after a submit button I think you need:

你的最后一个Form::input可能是问题,它的输入格式不正确,或者如果你在提交按钮之后,我认为你需要:

Form::submit('Contact Me',['class'=>'btn btn-primary form-control'])

Also install whoops if you havent already done so: use this article to help. https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5

如果您还没有安装 whoops,也请安装:使用这篇文章来提供帮助。https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5

Whoops will help indicate the error in the view/

哎呀将有助于指出视图中的错误/