Constant arrays

suggest change

Arrays can be used as plain constants and class constants from version PHP 5.6 onwards:

Class constant example

class Answer {
    const C = [2,4];
}

print Answer::C[1] . Answer::C[0]; // 42

Plain constant example

const ANSWER = [2,4];
print ANSWER[1] . ANSWER[0]; // 42

Also from version PHP 7.0 this functionality was ported to the define function for plain constants.

define('VALUES', [2, 3]);
define('MY_ARRAY', [
    1,
    VALUES,
]);

print MY_ARRAY[1][1]; // 3

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Constants:
* Constant arrays

Table Of Contents
2 Arrays
4 Types
10 Cookies
14 JSON
15 SOAP
17 cURL
19 XML
21 Traits
34 Constants
35 UTF-8
36 URLs
38 PHPDoc
41 Loops
44 Closur
72 YAML
77 Cache
78 Streams
81 PDO
82 SQLite3
83 Sockets
87 MongoDB
93 IMAP
94 Redis
95 Imagick
102 APCu
108 PSR