user2945856
user2945856

Reputation: 77

Accessing static array

How do I access values of a static array in PHP?

$anyVar = self::MY_ARRAY['identifier']

throws 'unexpected [ after MY_ARRAY' at me.

Upvotes: 0

Views: 56

Answers (1)

John Conde
John Conde

Reputation: 219834

You're missing your dollar sign

$anyVar = self::$MY_ARRAY['identifier'];

FYI, naming variables in uppercase should be reserved to constants by convention.

Upvotes: 1

Related Questions