PHP 8.4.24 Released!

Voting

: four plus three?
(Example: nine)

The Note You're Voting On

nepomuk at nepda dot de
10 years ago
[Editor's note: that is already possible as of PHP 5.6.0.]

Note, as of PHP7 it is possible to define class constants with an array.

<?php
class MyClass
{
    const ABC = array('A', 'B', 'C');
    const A = '1';
    const B = '2';
    const C = '3';
    const NUMBERS = array(
        self::A,
        self::B,
        self::C,
    );
}
var_dump(MyClass::ABC);
var_dump(MyClass::NUMBERS);

// Result:
/*
array(3) {
    [0]=>
  string(1) "A"
    [1]=>
  string(1) "B"
    [2]=>
  string(1) "C"
}
array(3) {
    [0]=>
  string(1) "1"
    [1]=>
  string(1) "2"
    [2]=>
  string(1) "3"
}
*/
?>

<< Back to user notes page

To Top