Home > Backend Development > PHP Tutorial > Use isset with caution in PHP to determine whether an array has a key_PHP Tutorial

Use isset with caution in PHP to determine whether an array has a key_PHP Tutorial

WBOY
Release: 2016-07-13 17:16:07
Original
922 people have browsed it

The article mainly talks about some examples about using isset with caution in PHP to determine whether there is a key in the array.

Connected to the code, I don’t know if it’s a problem with the php5.4 version, or if it’s just like this...

The code is as follows
 代码如下 复制代码

$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)

Copy code
$a['hello'] = ’123‘;
$a['xx'] = NULL;

var_dump(isset($a['hello'])); //bool(true)

var_dump(isset($a['xx'])); //bool(false)

# This should be used to judge
var_dump(array_key_exists(‘xx’, $a)); //bool(true)

http://www.bkjia.com/PHPjc/628694.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/628694.html
TechArticle
The article mainly talks about some examples about using isset with caution in PHP to determine whether there is a key in the array. Connected to the code, I don’t know if it’s a problem with the php5.4 version or it’s always like this. The code is as follows. Copy...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template