(PHP) isset() vs empty() vs is_null()

IT/Programming/PHP 2014. 10. 29. 15:16

isset(), empty(), is_null() 은 모두 해당 변수에 값이 들어있는지 안들어있는지를 체크하는 함수이다.

하지만 이 3가지 함수 모두 <비어있다> 를 판단하는 기준이 서로 조금씩 달라 혼선이 생길 수 있다.

 

아래의 테이블을 참고하도록 한다.

 

 

PHP 5.3.8 기준으로 테스트되었다.

비어있는 칸은 bool(false) 를 의미한다.

 

 

 

 

 

 

PHP Manual

isset() - http://php.net/manual/en/function.isset.php

empty() - http://php.net/manual/en/function.empty.php

is_null() - http://php.net/manual/en/function.is-null.php

 

참고 링크 :

https://www.virendrachandak.com/techtalk/php-isset-vs-empty-vs-is_null/

 

 

설정

트랙백

댓글