2026 년 4 월

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

 
그누스킨 그누소스 소스변경 소스문법 홈준비 기타
 
작성일 : 07-02-03 12:47
[소스문법] 제어 구조의 대체 문법
 글쓴이 : Morning (124.♡.110.84)
조회 : 3,916  
PHP는 제어 구조를 위해 대체 문법을 제공한다; 즉 if, while, for, foreach, 그리고 switch. 각 경우에 대체 문법의 기본형태는 괄호열기를 콜른 (:)으로 대체하고 괄호닫기는 각각 endif;, endwhile;, endfor;, endforeach;, 또는 endswitch;으로 대체한다.

<?php if ($a == 5): ?>
A는 5와 같다
<?php endif; ?> 

위 예에서는 대체 문법으로 쓰여진 if구문안에 "A는 5와 같다" HTML 블록이 포함되어있다. 이 HTML 블록은 $a가 5와 같을때만 출력될것이다.

대체 문법은 else와 elseif문에도 적용이 된다. 다음은 elseif와 else문 과 같이 있는 if문 절의 대체 형태이다:

<?php
if ($a == 5):
  echo "a는 5와 같다";
  echo "...";
elseif ($a == 6):
  echo "a는 6과 같다";
  echo "!!!";
else:
  echo "a는 5도 아니고 6도 아니다";
endif;
?> 

더 많은 예는while, for와 if섹션에 있다.
주님과 함께 모닝커피를

 
 

Total 167
번호 제   목 글쓴이 날짜 조회
32 [소스문법] 제어 구조의 대체 문법 Morning 02-03 3917
31 [소스문법] elseif Morning 02-03 3707
30 [소스문법] else Morning 02-03 3971
29 [소스문법] if Morning 02-03 3828
28 [소스문법] for (1) Morning 02-03 3724
27 [그누소스] 검색창에 통합검색 셀렉트 박스를 넣는 방법 Morning 02-02 3988
26 [소스문법] 흐르는 글 Morning 01-31 3904
25 [소스문법] 보더를 이용해서 box 만들기 Morning 01-26 4971
24 [소스문법] A라면 A해라 Morning 01-22 3863
23 [소스문법] gd_gallery image resizing Morning 01-20 5182
22 [그누스킨] 다중게시판 Morning 01-18 3265
21 [그누스킨] morning_webzine1 Morning 01-17 3019
20 [그누스킨] morning_webzine2 Morning 01-14 3169
19 [그누스킨] morning_webzine Morning 01-14 3468
18 [소스문법] 여분필드에 기본값 입력하기 (1) Morning 01-14 4235
 1  2  3  4  5  6  7  8  9  10    

Therefore, holy brothers, who share in the heavenly calling,
fix your thoughts on Jesus, the apostle and high priest whom we confess.
Let us fix our eyes on Jesus, the author and perfecter of our faith,
who for the joy set before him endured the cross, scorning its shame,
and sat down at the right hand of the throne of God