语法错误,意外 '中'(T_STRING)Laravel 5
问题描述:
控制器类作者语法错误,意外 '中'(T_STRING)Laravel 5
public $restful=true;
public function index()
{
$author = Author::all();
return \View::make('authors.index', ['authors' => $author]);
}
为作者作者
@extends('layouts.default')
@section('content')
<h1>THIS IS AUTHOR'S PAGE</h1>
<ul>
@foreach($authors in $author)
<li>{{ $author->name }}</li>
@endforeach
</ul>
@endsection
显示页面
class Author extends Model
{
protected $table = 'authors';
}
查看文件Model类作者
<!DOCTYPE html>
<HTML>
<HEAD><TITLE>Testing</TITLE></HEAD>
<BODY>
@yield('content')
</BODY>
</HTML>
我收到错误响应。
FatalErrorException in 6d4e39a843ef4ce0421f063e7b907f68 line 5:
syntax error, unexpected 'in' (T_STRING)
我无法确切地知道这个错误是从,因为它返回一个字符串代码,我无法interpret.What我能做的到来。谢谢。
答
我觉得应该是as
而不是in
(in
没有意义顺序):
@foreach($authors as $author)
<li>{{ $author->name }}</li>
@endforeach
答
我想你应该更换
@foreach($authors in $author)
与
@foreach($author as $authors)
你给我的日子上色了!!!!!!! –