Dynamic use of constants

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Dynamic use of constants

Post by shiznatix »

I have constants that look like this:

USERS_RAKETRACKING_JANUARY
USERS_RAKETRACKING_FEBUARY
etc.

and I am trying to dynamically call them in a loop as I loop through the months like this:

Code: Select all

USERS_RAKETRACKING_.$val
but of course that does not work. so I was wondering if that I am trying to do is even possible or if I need to go about this another way.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

constant('USERS_RAKETRACKING_'.$val)
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

You may want to consider stuffing these "constant" values into a registry.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Post Reply