0

I have a public variable declared as array in class which is being used locally in class but I'm unable to use it outside the class.

below is the code

class permissions {
    public static $departments = array(
        "Engineering"=>array(
            'ONM','ESS','NP','NC','Engineering'
            )
        );

        // remaining code is left out for brevity

}

How i can access $department in class declaration?

I was expecting this way permissions::departments; but getting error Undefined class constant 'departments'.

Amal Murali
  • 75,622
  • 18
  • 128
  • 150

1 Answers1

3

Try to use combination of scope resolution operator :: and dollar sign $:

print_r(permissions::$departments);

Manual

Community
  • 1
  • 1
BlitZ
  • 12,038
  • 3
  • 49
  • 68