PHP 라라벨 블레이드 문법 - 제어구조

2022. 5. 10. 09:00PHP/Laravel8.X

728x90

https://riptutorial.com/laravel/example/4607/control-structures

라라벨 블레이드 템플릿은 편리한 PHP 제어 문법을 제공한다.
각각의 제어 구조는 @[structure] 로 시작하여 @[endstructure] 로 끝난다.
이 블록 안에서 우리는 자유롭게 HTML과 블레이드 문법을 섞어 쓸 수 있다.

쉽게 말하면

if (조건문) {

}

대신에

@if

@endif

를 쓴다는 것이다.

루프 안에서는 현재 루프 상태 정보를 담고 있는 특별한 변수 $loop를 변수를 사용할 수 있다.

$loop->index The index of the current loop iteration (starts at 0).
$loop->iteration The current loop iteration (starts at 1).
$loop->remaining The remaining loop iterations.
$loop->count The total number of items in the array being iterated.
$loop->first Whether this is the first iteration through the loop.
$loop->last Whether this is the last iteration through the loop.
$loop->depth The nesting level of the current loop.
$loop->parent When in a nested loop, the parent's loop variable.

 

728x90
반응형