WEB언어/PHP
PHP의 empty
saltdoll
2018. 3. 9. 01:25
반응형
http://php.net/manual/en/function.empty.php
empty에 해당 하는 요소들.
Return Values ¶
Returns FALSE
if var
exists and has a non-empty, non-zero value. Otherwise returns TRUE
.
The following values are considered to be empty:
- "" (an empty string)
- 0 (0 as an integer)
- 0.0 (0 as a float)
- "0" (0 as a string)
NULL
FALSE
- array() (an empty array)
example empty() / isset()
<?php $var = 0; // Evaluates to true because $var is empty if (empty($var)) { echo '$var is either 0, empty, or not set at all'; } // Evaluates as true because $var is set if (isset($var)) { echo '$var is set even though it is empty'; } ?> |
반응형