# Fatal error: isset(CONST_ARRAY['key']) PHP 5.6

- Thread: https://externals.io/message/86374
- Original archive: https://news-web.php.net/php.internals/86374
- Started by S.A.N on 2015-05-25T10:46:55+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #86374 — S.A.N — 2015-05-25T10:46:55+00:00

URL: https://externals.io/message/86374#86374

<?php

const CONST_ARRAY =
[
    'key' => 'value'
];

isset(CONST_ARRAY['key']); // Fatal error: Cannot use isset() on the
result of an expression (you can use "null !== expression" instead)

?>

It is design, or a bug?

---

## #86376 — Christoph Becker — 2015-05-25T13:00:53+00:00

URL: https://externals.io/message/86374#86376 · In reply to: #86374

S.A.N wrote:

> <?php
> 
> const CONST_ARRAY =
> [
>     'key' => 'value'
> ];
> 
> isset(CONST_ARRAY['key']); // Fatal error: Cannot use isset() on the
> result of an expression (you can use "null !== expression" instead)
> 
> ?>
> 
> It is design, or a bug?

It is by design; the documentation states[1]:

| isset() only works with variables as passing anything else will
| result in a parse error.

[1]
<http://php.net/manual/en/function.isset.php#refsect1-function.isset-notes>

-- 
Christoph M. Becker

---

## #86377 — S.A.N — 2015-05-25T13:09:42+00:00

URL: https://externals.io/message/86374#86377 · In reply to: #86376

> It is by design; the documentation states[1]:
>
> | isset() only works with variables as passing anything else will
> | result in a parse error.
>
> [1]
> <http://php.net/manual/en/function.isset.php#refsect1-function.isset-notes>

Ok, the way it works in PHP 7.

But the speed of access to const the array (ARR['key']) is 5 times
slower, in comparison with the variable ($arr['key']) :(

---

## #86378 — Jan Ehrhardt — 2015-05-25T15:09:43+00:00

URL: https://externals.io/message/86374#86378 · In reply to: #86377

"S.A.N" in php.internals (Mon, 25 May 2015 16:09:42 +0300):
> > […]
>
>Ok, the way it works in PHP 7.

There was some discussion on contant arrays on Stackoverflow with an
answer by Andrea Faulds (with a link to changes between 5.6 and 7.0):
http://stackoverflow.com/a/27413238/872051

Jan

---

## #86386 — S.A.N — 2015-05-25T18:32:34+00:00

URL: https://externals.io/message/86374#86386 · In reply to: #86378

> There was some discussion on contant arrays on Stackoverflow with an
> answer by Andrea Faulds (with a link to changes between 5.6 and 7.0):
> http://stackoverflow.com/a/27413238/872051

Ok, thank.

Why the speed of access to const the array ARR['key'] is 500% slower,
in comparison with the variable $arr['key']?
