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

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

개발

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

페이지 정보

profile_image
작성자 최고관리자 (61.♡.24.46)
댓글 0건 조회 4,736회 작성일 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 387건 1 페이지
  • RSS
개발 목록
번호 제목 조회 추천 날짜
38761005-27
386511004-07
3851339002-02
3841200001-09
3831479012-25
3821237012-15
381985012-10
380579012-03
379684011-26
378590011-04
3771199009-08
3761511008-11
3751563008-10
3741888007-10
3731331007-03
3721786006-06
3711581004-23
3701589004-20
3692694004-19
3681274004-12

검색


사이트 정보

Copyright © Baragi.Net. All rights reserved.