1.2.333. Define Constants With Array¶
PHP has the ability to define an array as a constant, using the define() native call. This was not possible until that version, only with the const keyword.
This was introduced in PHP 7.0. It also applies to the const
keyword and to class constants.
<?php
//Defining an array as a constant
define('MY_PRIMES', [2, 3, 5, 7, 11]);
const MY_OTHER_NUMBERS = [12, 13, 15, 17, 111];
?>
1.2.333.1. Connex PHP features¶
1.2.333.1.1. Specs¶
Short name |
Php/DefineWithArray |
Rulesets |
All, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56 |
Exakat since |
0.8.4 |
PHP Version |
With PHP 7.0 and more recent |
Severity |
Critical |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
Available in |