Home  >  Article  >  Backend Development  >  php 中如何判断是否为空

php 中如何判断是否为空

WBOY
WBOYOriginal
2016-06-20 12:37:28977browse

```<?phperror_reporting(0);$a = ""; // 空$a = null; // 空$a = array(); // 空$a = false; // 空$a = 0; // 空$a = '0'; // 空$a = 1; // 不空$a = true; // 不空$a = array(1 => '1'); // 不空$a = ';'; // 不空$a = function () {echo 1;}; // 不空class a {};$a = new a(); // 不空if (!empty($a)) {    echo '不空';} else {    echo '空';}echo PHP_EOL;```

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn