Laravel中的Blade中的"意外的_data T_String"

use*_*216 7 php laravel-4

我在他的网站上跟随Jeffrey Ways laracasts一直在学习,但不幸的是我在某个地方犯了错误,我不知道那是哪里.我收到以下错误.

https://laracasts.com/series/laravel-from-scratch

Symfony \ Component \ Debug \ Exception \ FatalErrorException

syntax error, unexpected '__data' (T_STRING)

<?php $__env->startSection('content'); ?>
<h1>All Users</h1>
<?php foreach($users as $user): ?>
<li><?php echo link_to("/users/{$user->username}", $user->username); ?></li>
<?php endforeach; ?>;
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.default, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
Run Code Online (Sandbox Code Playgroud)

我不太清楚为什么我会遇到这个问题.有人可以向我解释一下,所以我能理解吗?

jos*_*osh 39

我想你错过了最后一行的单引号.试试这个:

<?php $__env->startSection('content'); ?>
<h1>All Users</h1>
<?php foreach($users as $user): ?>
<li><?php echo link_to("/users/{$user->username}", $user->username); ?></li>
<?php endforeach; ?>;
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.default', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,在我的情况下,我也错过了单引号.☺ (2认同)