Dynamic Enumeration in PHP. Possible? Sensible?
I am building an API which will accept a variety of metrics from an iPhone application.
The App Programmer has requested that the API be able to handle types of metrics the API does not yet know about. I would like to use an enumeration to list the current t开发者_StackOverflow中文版ypes of Metrics, but new metrics would have to be added as they are pushed to the server.
Has anyone seen this done before? I've thought about using a DB instead of an enum, but that seems really messy.
Any thoughts?
Don't use an enumeration. Enumerations are primarily useful for when the entire range of values is known ahead of time; this is clearly not your case.
精彩评论