【发布时间】:2014-07-08 18:21:09
【问题描述】:
我想在使用之前检查$table['key'] 是否存在。这样做的正确方法是什么?
我见过很多不同的代码,但我不知道它们是否都等价和正确。以下是几个例子:
// 1
if(isset($table['key'])) { ... }
// 2
if(isset($table) and isset($table['key'])) { ... }
// 3
if(isset($table) and array_key_exists('key',$table)) { ... }
【问题讨论】:
标签: php arrays array-key-exists