Skip to content
Advertisement

Get value of dynamically chosen class constant in PHP

I would like to be able to do something like this:

JavaScript

This doesn’t work. Is there a straightforward way of doing something equivalent? Note that I’m stuck with the class; it’s in a library I can’t rewrite. I’m writing code that takes arguments on the command line, and I would really like it to take symbolic names instead of id numbers.

Advertisement

Answer

Use the constant() function:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement