No, I'm afraid not. I guess I still haven't explained this very well 🙂 Let me try a different way.
Say an included PHP script conditionally defines several constants like so:
<?php
$type = (something done on the disk maybe)
switch( $type ) {
case 0:
define( "FOO", 0 );
$constName = "FOO";
break;
case 1:
define( "BAR", 1 );
$constName = "BAR";
break;
}
?>
Now assume for a moment that this actually makes sense to do 🙂 Now assume I have another PHP script that includes/requires the above. And say I don't want to use something like defined() to check for the existence of each constant (maybe to make it easier to update the code in the future?). Given only the variable $constName, is there a way to get at the constant $constName specifies? ie. if I was using variables, I'd just do $$constName, but since there are constants we're talking about there's no way to do that.
Is there some sort global array like $CONSTANTS[] indexed by constant name? Something like this? Should there be?
I know this is odd behaviour, and likely pretty rare, but I have in fact run into a situation where this would extremelly helpful; without going into gorey details, it's a meta-editor of sorts (editor for an editor 🙂 where the object is to make it as flexible as possible.