<?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?
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
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']) :(
"S.A.N" in php.internals (Mon, 25 May 2015 16:09:42 +0300):
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-notesOk, 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
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']?