PHP heredoc 히어독에 조건문 사용하기 > 서버관리

본문 바로가기

사이트 내 전체검색

뒤로가기 서버관리

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

페이지 정보

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

본문

기본적으로 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

댓글목록 0

등록된 댓글이 없습니다.

전체 91건 4 페이지
게시물 검색
Copyright © Baragi.Net All rights reserved.
PC 버전으로 보기