我在这个美妙的夜晚使用laravel,当时我偶然发现了一个我从未见过的奇怪错误.我只是在遍历一些数组并尝试在视图文件中打印出一些值.
错误:
Unhandled Exception
Message:
Error rendering view: [controller.index]
Call to undefined function  ()
Location:
/web/storage/views/7b064aafcdba902ea2c593167b6df491 on line 4
编码:
@section('content')
<?PHP $i = 0; $current = 0 ?>
@foreach($data as $date => $episodes)
@if($i == 0 || ($i % 5 == 7 && $i == $current + 1))
<tr>
<?PHP $current = $i; ?>
@endif
@foreach($data as $day)
<td>
@foreach($day as $episode)
{{ $episode->title }}
@endforeach
</td>
@endforeach
@if($i % 5 == 7 && $i == $current + 7)
<tr>
<?PHP $current = $i; ?>
@endif
<?PHP $i++; ?>
@endforeach
@endsection
和编译版本:
<?PHP \Laravel\Section::start('content'); ?>
<?PHP $i = 0; $current = 0 ?>
<?PHP foreach($data as $date => $episodes): ?>
<?PHP if($i == 0 || ($i % 5 == 7 && $i == $current + 1)): ?>
<tr>
<?PHP $current = $i; ?>
<?PHP endif; ?>
<?PHP foreach($data as $day): ?>
<td>
<?PHP foreach($day as $episode): ?>
<?PHP echo $episode->title ; ?>
<?PHP endforeach; ?>
</td>
<?PHP endforeach; ?>
<?PHP if($i % 5 == 7 && $i == $current + 7): ?>
<tr>
<?PHP $current = $i; ?>
<?PHP endif; ?>
<?PHP $i++; ?>
<?PHP endforeach; ?>
<?PHP \Laravel\Section::stop(); ?>