Home > Backend Development > PHP Tutorial > empty跟isset的解决之道 - PHP变量是否定义的判断

empty跟isset的解决之道 - PHP变量是否定义的判断

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 13:07:27
Original
1055 people have browsed it

empty和isset的解决之道 - PHP变量是否定义的判断

当访问一个未定义的变量时,PHP会产生警告

?

使用之前可以用empty();或 isset()来判断变量是否定义

$arr['k1']; 尽管$arr是未定义的,还是可以用用这两个函数来判断

如果使用 如果使用if判断,将会产生? Undefined variable 的警告

?

一个变量的未定义与和将变量设为null是不同的,用unset()会将变量置为未定义

?

函数中无return或return;调用此函数得到结果为NULL

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
Return value problem
From 1970-01-01 08:00:00
0
0
0
Return JSON response via PHP
From 1970-01-01 08:00:00
0
0
0
Usage of return
From 1970-01-01 08:00:00
0
0
0
Why not return data in json format?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template