how to define enums in PHP under a specific scope

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
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

how to define enums in PHP under a specific scope

Post by jasongr »

Hello

I am using PHP5 and I would like to define constants that should only be defined under a specific scope (for example a class scope).

Is there a way to define enums under a class scope so that they won't occupy memory in the class (like constants do)?

If I would define my constants as:
public static $CONSTANT = 1;
then the static variable will occupy memory for the class

I know that constants that are defined using define() do not take memory because the preprocessor replaces them before the code runs.
Is is also true in PHP?

regards
Jason
Post Reply