search
Homephp教程php手册isset 和empty 区别: php中is_null,empty,isset,unset 的区别详细介绍


s_null, empty, isset,
unset 我们先来看看这4个函数的描述。
isset
判断变量是否已存在(配置)
unset 把变量删除(释放)掉
empty 判断变量是否为空
is_null 判断变量是否为NULL
ok,已经开始搞人了。那么开始,这4个函数中除了unset,其他3个都是判断函数,unset首先出局,因为他不会搞错,其次是is_null,我们可以把它看成是!isset,是isset的一个逆操作,下面一张表可以很清楚的说明他们之间的关系:
变量
      empty    is_null      isset
$a=””      true       false        true
$a=null    true       true        false
var $a      true      true         false
$a=array() true    false         true
$a=false   true      false         true
$a=15     false      false         true
$a=1       false      false         true
$a=0       true      false         true
$a=”0”    true      false         true
$a=”true” false    false         true
$a=”false” false    false        true
从中我们可以发现只要变量是否为”
“或者0,或者是false和null,只要是这些值empty都会返回true,而isset是判断变量是否存在,只要你这个变量不是null或未赋值,返回结果都是true,而is_null正好是isset的反结果。
当然如果只是想做如下工作:
echo !isset($_GET['a']); //如果得不到变量a的值
echo empty($_GET['a']); //如果变量a的值是空
那么结果都是一样的,都可以用。
本文链接http://www.cxybl.com/html/wlbc/Php/20130729/39379.html



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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools