isset如何在评估数组属性时不抛出错误?

How does isset not throw an error when evaluating array properties?

每当我尝试访问不存在的数组的 属性 时,php 会抛出一个 ERROR_NOTICE,内容如下:

Notice: Undefined offset: BLANK in BLANK on line BLANK

$a = array("a","b","c");

$a[4]; //throws an error

相反,如果我使用 isset 来测试此 属性 是否存在,则不会抛出此错误。

$a = array("a","b","c");

isset($a[4]); //does not throw an error

既然 php 会在将参数传递给函数之前对其求值,那么 isset 如何避免抛出错误?

isset 不是函数而是 语言结构:

Note: Because this is a language construct and not a function, it cannot be called using variable functions.

它不是函数调用的方式,而是语言特殊处理的方式。 empty.

也是如此