개발
PHP heredoc 히어독에 조건문 사용하기
마스타
2015. 10. 11. 11:00
300x250
기본적으로 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
http://www.baragi.net/bbs/board.php?bo_table=server&wr_id=8543
300x250