문제

Is it need to use blade foreach like this

<!-- Blade foreach -->
@foreach ($users as $user)
 <div class="user">{{ $user->name }}</div>
@endforeach

Because blade PHP template is very similar to C# Razor, is ti possible to use foreach loop like this

<!-- Blade foreach -->
@foreach ($users as $user)
 <div class="user">{{ $user->name }}</div>

Does I must always end foreach like this @endforeach??

도움이 되었습니까?

해결책

Yes, Blade templating does not use indents to recognize the end of controle structures. Behind the scenes it will all be converted to regular PHP. It is just a more convenient and cleaner way to write your views. That is why a {{ $var }} outputs the following <?php echo $var;?>.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top