empty,isset,is_null I encountered some problems when using these functions. It even brings some security risks to your own programs. Many times, isset and empty are considered similar. Therefore, during development, I did not pay attention to it. When it was judged as a process, bug problems appeared.
1. Examples
a. A variable is not defined, how should we judge it?
view source
print?
01
<?php
02
#不存在<font color="#aa7700">$test</font>变量
03
04
<font color="#aa7700">$isset</font>= isset(<font color="#aa7700">$test</font>)?<font color="#0000ff">"test is define!"</font>:<font color="#0000ff">"test is undefine!"</font>;
<font color="#aa7700">$empty</font>=!<font color="#ff1493">empty</font>(<font color="#aa7700">$test</font>)?<font color="#0000ff">"test is define!"</font>:<font color="#0000ff">"test is undefine!"</font>;
<font color="#aa7700">$is_null</font>=<font color="#ff1493">is_null</font>(<font color="#aa7700">$test</font>)?<font color="#0000ff">"test is define!"</font>:<font color="#0000ff">"test is undefine!"</font>;
The result is out: empty and isset will first check whether the variable exists, and then detect the variable value. And is_null just checks the variable value directly to see if it is null, so if the variable is not defined, an error will occur!
1 2 3 4
http://www.bkjia.com/PHPjc/632335.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632335.htmlTechArticleempty,isset,is_null I encountered some problems when using these functions. It even brings some security risks to your own programs. Many times, isset and empty are considered similar. So...
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