Home » Php » php – "Unexpected _data T_String" in Blade, Laravel

php – "Unexpected _data T_String" in Blade, Laravel

Posted by: admin July 12, 2020 Leave a comment

Questions:

I was following along with Jeffrey Ways laracasts on his website and was really learning but unfortunately I made an error somewhere and I don’t know where that is. I am receiving the following error.

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(); ?>

I’m not quite sure why I am getting this issue. Can someone explain it to me please so I can understand?

How to&Answers:

I think you missed a single quote on the last line. Try this:

<?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(); ?>