Get a list of class constants

Possible duplicate:
Can I get CONST in a PHP class?

class ApplicationMode
{
    const production = 0;
    const development = 1;
    const testing = 2;
    public function getApplicationModes()
    {
        return get_class_vars('ApplicationMode');
    }
}

I have such a class, and in the getApplicationModes method I would like to return a list of all constants as an array (key => value). The problem is that get_class_vars does not list constants. is there any way to get a list of all class constants?

+3
source share

Source: https://habr.com/ru/post/1768298/


All Articles