Access public static variable outside the class

Muhammad Haseeb Khan

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'.

BlitZ

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

print_r(permissions::$departments);

Manual

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Access public static variable inside class in function php

From Dev

PHP: static variable outside of class

From Dev

Why aren't we allowed to access a private static member outside class without public member function?

From Dev

How to get access to a public static member variable

From Dev

Whether redeclare a const static variable outside a class or not

From Dev

Laravel: Get access to class-variable from public static function (basic oop issues)

From Dev

Public static variable not recognized outside constructor or method body

From Dev

How to access an 'outside' variable in a class func in swift?

From Dev

How to access a CardLayout variable from an outside class?

From Dev

Access variable in function, outside class without error

From Dev

Access a static variable from a class stored in a variable

From Dev

Access public static class' state from a separate class file

From Dev

Why we declare static variable in a class & the definition in outside of the class?

From Dev

Access private static method from outside the class C++

From Java

How to access a public static final member in a Java class from Scala?

From Dev

How to access a public static final member in a Java class from Scala?

From Dev

How to access private static variable in static member function of another class?

From Dev

Why is the static variable initialized with redeclaration of static variable outside the class? Can't we just initialize it instead of redeclaring it?

From Dev

How to access outside class variable data in Objective-C?

From Dev

Cannot declare a variable with public access in a class from a module

From Dev

How to access from 'private method' to 'public variable', in Javascript class

From Dev

How to access a non-public variable in a base class?

From Dev

PHP Access public variable changed in constrict from child class

From Dev

access outside variable in macro?

From Dev

access outside variable in macro?

From Dev

Access object outside of class

From Dev

How can I access to a public final static list declared into an utility class from another class in a Java application?

From Dev

Public Static variable in excel vba

From Dev

Life of public static variable in Android

Related Related

  1. 1

    Access public static variable inside class in function php

  2. 2

    PHP: static variable outside of class

  3. 3

    Why aren't we allowed to access a private static member outside class without public member function?

  4. 4

    How to get access to a public static member variable

  5. 5

    Whether redeclare a const static variable outside a class or not

  6. 6

    Laravel: Get access to class-variable from public static function (basic oop issues)

  7. 7

    Public static variable not recognized outside constructor or method body

  8. 8

    How to access an 'outside' variable in a class func in swift?

  9. 9

    How to access a CardLayout variable from an outside class?

  10. 10

    Access variable in function, outside class without error

  11. 11

    Access a static variable from a class stored in a variable

  12. 12

    Access public static class' state from a separate class file

  13. 13

    Why we declare static variable in a class & the definition in outside of the class?

  14. 14

    Access private static method from outside the class C++

  15. 15

    How to access a public static final member in a Java class from Scala?

  16. 16

    How to access a public static final member in a Java class from Scala?

  17. 17

    How to access private static variable in static member function of another class?

  18. 18

    Why is the static variable initialized with redeclaration of static variable outside the class? Can't we just initialize it instead of redeclaring it?

  19. 19

    How to access outside class variable data in Objective-C?

  20. 20

    Cannot declare a variable with public access in a class from a module

  21. 21

    How to access from 'private method' to 'public variable', in Javascript class

  22. 22

    How to access a non-public variable in a base class?

  23. 23

    PHP Access public variable changed in constrict from child class

  24. 24

    access outside variable in macro?

  25. 25

    access outside variable in macro?

  26. 26

    Access object outside of class

  27. 27

    How can I access to a public final static list declared into an utility class from another class in a Java application?

  28. 28

    Public Static variable in excel vba

  29. 29

    Life of public static variable in Android

HotTag

Archive