Home >Backend Development >PHP Tutorial >Detailed explanation of judgment based on empty function_PHP tutorial

Detailed explanation of judgment based on empty function_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:05:38922browse

$a = '';
echo '1.-----------'.($a == '').'
';
echo '2.-----------'.($a == null).'
';
echo '3.-----------'.($a == false).'
';
echo '4.-----------'.($a == '0').'
';
echo '5.-----------'.($a == 0).'
';
$a = null;
echo '6.-----------'.($a == '').'
';
echo '7.-----------'.($a == null).'
';
echo '8.-----------'.($a == false).'
';
echo '9.-----------'.($a == '0').'
';
echo '10.-----------'.($a == 0).'
';
$a = '0';
echo '11.-----------'.($a == '').'
';
echo '12.-----------'.($a == null).'
';
echo '13.-----------'.($a == false).'
';
echo '14.-----------'.($a == '0').'
';
echo '15.-----------'.($a == 0).'
';
$a = 0;
echo '16.-----------'.($a == '').'
';
echo '17.-----------'.($a == null).'
';
echo '18.-----------'.($a == false).'
';
echo '19.-----------'.($a == '0').'
';
echo '20.-----------'.($a == 0).'
';
$a = false;
echo '21.-----------'.($a == '').'
';
echo '22.-----------'.($a == null).'
';
echo '23.-----------'.($a == false).'
';
echo '24.-----------'.($a == '0').'
';
echo '25.-----------'.($a == 0).'
';
输出的结果
1.-----------1
2.-----------1
3.-----------1
4.-----------
5.-----------1
6.-----------1
7.-----------1
8.-----------1
9.-----------
10.-----------1
11.-----------
12.-----------
13.-----------1
14.-----------1
15.-----------1
16.-----------1
17.-----------1
18.-----------1
19.-----------1
20.-----------1
21.-----------1
22.-----------1
23.-----------1
24.-----------1
25.-----------1


$a = '';//0|'0'|false|null 输出的结果一致
echo '1.-------'.(!empty($a) == '').'
';
echo '2.-------'.(!empty($a) == null).'
';
echo '3.-------'.(!empty($a) == false).'
';
echo '4.-------'.(!empty($a) == '0').'
';
echo '5.-------'.(!empty($a) == 0).'
';

输出的结果:
1.-------1
2.-------1
3.-------1
4.-------1
5.-------1

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/327672.htmlTechArticle$a = ''; echo '1.-----------'.($a == '').'br'; echo '2.-----------'.($a == null).'br'; echo '3.-----------'.($a == false).'br'; echo '4.-----------'.($a == '0').'br'; echo '5.-----...
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