PHP heredoc 히어독에 조건문 사용하기 > 개발

본문 바로가기
사이트 내 전체검색

개발

PHP heredoc 히어독에 조건문 사용하기

페이지 정보

profile_image
작성자 최고관리자 (61.♡.24.46)
댓글 0건 조회 4,800회 작성일 15-10-10 17:17

본문

기본적으로 heredoc 에서는 if 조건문을 사용할 수 없다.
그래서 heredoc 밖에서 조건문으로 변수를 구성한 후에 히어독 안에서 뿌려 주면 된다.

if(isset($variablename)) {
  $outputVar = "...some text 1";
} else {
    $outputVar = "...some text 2";
}

print <<<EOD
<h3>Caption</h3>
{$outputVar}
EOD;

** 출처 : http://stackoverflow.com/questions/16466356/can-we-use-php-if-statements-in-eod-syntax-code

추천0

댓글목록

등록된 댓글이 없습니다.

Total 389건 19 페이지
  • RSS
개발 목록
번호 제목 조회 추천 날짜
292247003-09
282213003-15
271595003-22
263479004-10
251431004-10
241961004-11
231976004-11
221344004-12
212770004-19
201656004-20
191639004-23
181872006-06
171375007-03
161985007-10
151669008-10
141569008-11
131271009-08
12625011-04
11731011-26
10630012-03

검색


사이트 정보

Copyright © Baragi.Net. All rights reserved.