Home > php教程 > php手册 > php中慎用isset来判断数组是否存在key

php中慎用isset来判断数组是否存在key

WBOY
Release: 2016-06-13 10:17:00
Original
1571 people have browsed it

文章主要讲到关于php中慎用isset来判断数组是否存在key一些举例说明。

接上代码,  不知道是php5.4版本的问题, 还是本来就这样…

 代码如下 复制代码

$a['hello'] = ’123‘; 
$a['xx'] = NULL; 
 
var_dump(isset($a['hello'])); //bool(true) 
 
var_dump(isset($a['xx'])); //bool(false) 
 
# 应该使用这个来判断 
var_dump(array_key_exists(‘xx’, $a)); //bool(true)

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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template