PHP elseif

1 개요[ | ]

PHP elseif, else if
$a = 2;
if( $a == 1 ) {
	echo "a equals 1";
} elseif( $a == 2 ) {
	echo "a equlas 2";
} else {
	echo "?";
}
# a equals 2
$a = 2;
if( $a == 1 ):
	echo "a equals 1";
elseif( $a == 2 ):
	echo "a equlas 2";
else:
	echo "?";
endif;
<?php
$a = 2;
?>
<?php if ($a == 1): ?>
  a equals 1
<?php elseif ($a == 2): ?>
  a equals 2
<?php else: ?>
  ?
<?php endif ?>

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}