Reputation: 19551
I'd like to have arrays in my namespace which all functions in the namespace can access.
Is there no way to do this without resorting to names like $_MYNAMESPACE1_NAMESPACE2_NAMESPACE3_array1
? I suppose I could make a class in the namespace which contains static arrays, but that seems pretty inefficient.
Upvotes: 0
Views: 203
Reputation: 522024
Indeed, you cannot namespace variables. You can only namespace classes, interfaces, functions and constants. Since variables outside functions can only be accessed using the global
keyword, and global
is usually an anti-pattern, this is probably not the solution you're looking for anyway. A class seems like the way to go.
Upvotes: 2