【问题标题】:Laravel 5.1 View code result in syntax error, unexpected '')); ?>" ' (T_CONSTANT_ENCAPSED_STRING)Laravel 5.1 查看代码导致语法错误,意外'')); ?>" ' (T_CONSTANT_ENCAPSED_STRING)
【发布时间】:2016-02-29 00:43:17
【问题描述】:

我有这个警告:

糟糕,好像出了点问题。
1/1
f042f5969df1fc17d22527840a4806ba 第 59 行中的 FatalErrorException:
语法错误,意外 '')); ?>"
' (T_CONSTANT_ENCAPSED_STRING)
在 f042f5969df1fc17d22527840a4806ba 第 59 行

我试图找到问题,但仍然无法找到它。这是我的index.blade.php代码

<div class="container-fluid">
`@extends('admin.layout')`
`@section('content')`
    <div class="row page-title-row">
      <div class="col-md-6">
        <h3>Posts <small>» Listing</small></h3>
      </div>
      <div class="col-md-6 text-right">
        <a href="{{ URL('/admin/post/create')}}" class="btn btn-success btn-md">
          <i class="fa fa-plus-circle"></i> New Post
        </a>
      </div>
    </div>

    <div class="row">
      <div class="col-sm-12">

        `@include('admin.partials.errors')`
        `@include('admin.partials.success')`

        <table id="posts-table" class="table table-striped table-bordered">
          <thead>
            <tr>
              <th>Published</th>
              <th>Title</th>
              <th>Subtitle</th>
              <th data-sortable="false">Actions</th>
            </tr>
          </thead>
          <tbody>
            @foreach ($posts as $post)
              <tr>
                <td data-order="{{ $post->published_at->timestamp }}">
                  {!! $post->published_at->format('j-M-y g:ia') !!}
                </td>
                <td>{!! $post->title !!}</td>
                <td>{!! $post->subtitle !!}</td>
                <td>
                  <a href="{{ URL('/admin/post/'.$post->id.'/edit')}}"
                     class="btn btn-xs btn-info">
                    <i class="fa fa-edit"></i> Edit
                  </a>
                  <a href="{{ URL('/blog/'.$post->slug')}}"
                     class="btn btn-xs btn-warning">
                    <i class="fa fa-eye"></i> View
                  </a>
                </td>
              </tr>
            @endforeach
          </tbody>
        </table>
      </div>
    </div>
  </div>
`@stop`

-------------------------------------------------------------line 59

`@section('scripts')`    
<script>
        $(function() {
          $("#posts-table").DataTable({
            order: [[0, "desc"]]
          });
        });
      </script>
`@stop`

【问题讨论】:

  • 上述文件的第 59 行是什么,可以在 storage/framework/views 文件夹下找到

标签: php view laravel-5 laravel-blade


【解决方案1】:

尝试删除此 {{ URL('/blog/'.$post-&gt;slug')}} 末尾的引号,使其看起来像 {{ URL('/blog/'.$post-&gt;slug)}}

【讨论】:

  • 我已经删除了单引号,但它仍然无法正常工作
  • 尝试删除 {{ URL('/blog/'.$post-&gt;slug')}} 末尾的引号,使其看起来像 {{ URL('/blog/'.$post-&gt;slug)}}
  • 我更新了我原来的帖子,所以你可以接受它作为未来参考的答案:)
【解决方案2】:

这是你的错误

"{{ URL('/blog/'.$post->slug')}}"

slug 后面的单引号。

【讨论】:

  • 太好了,请您接受答案,以关闭此问题
猜你喜欢
  • 2020-01-19
  • 2012-03-10
  • 2014-02-25
  • 2015-01-23
  • 1970-01-01
  • 2012-11-13
  • 2017-11-04
相关资源
最近更新 更多