Here's my var, it's a const
:
const TWITTER_CACHE_REFRESH = 1440;
How can I access it in a method in the same class that I declare it? The class it's in has already been initialized by another class.
Here's my var, it's a const
:
const TWITTER_CACHE_REFRESH = 1440;
How can I access it in a method in the same class that I declare it? The class it's in has already been initialized by another class.
Use the following syntax
echo self::CONSTNAME;
In your case:
echo self::TWITTER_CACHE_REFRESH;
You can also replace self
with the class name if you wish but it is not recommended as if you change the class name then you have to change all references to its name in your code.
echo Classname::TWITTER_CACHE_REFRESH;