gpt4 book ai didi

php - 为什么在数组中没有这样的索引时返回一个字符串值?

转载 作者:行者123 更新时间:2023-12-04 22:27:26 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Strange behavior with isset() returning true for an Array Key that does NOT exist

$arr = array(
'application' => array (
'environment' => 'development',
'mode_debug' => 1,
'key' => '123456abcdefg',
'debug_soft' =>
'firephp',
'aaa' => array (
'bbb' => '111',
'ccc' => '222',
'ddd' => array (
'eee' => '12345',
),
),
),
'database' => array (
'host' => 'localhost',
'database' => '',
'username' => '',
'password' => '',
'charset' => 'utf8',
'prefix' => '',
),
);


if(isset($arr["application"]["aaa"]["ddd"]["eee"]['out']) && !empty($arr["application"]["aaa"]["ddd"]["eee"]['out'])){
echo "a";
echo '<br />';
var_dump($arr["application"]["aaa"]["ddd"]["eee"]['out']);
}else{
echo "b";
}

返回:

a
string(1) "1"

但是 '$arr' 数组中没有 'out' 索引,所以为什么它返回 'string(1) "1"'?

手册没有帮助,因为它只对一维数组进行采样:

$a = array ('test' => 1, 'hello' => NULL);

var_dump( isset ($a['test']) ); // TRUE
var_dump( isset ($a['foo']) ); // FALSE
var_dump( isset ($a['hello']) ); // FALSE

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com