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

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

WBOY
WBOYOriginal
2016-06-13 10:17:001518browse

文章主要讲到关于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)

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