If you want to filter through and return only the prefix for your constants (i.e. you have constants with a naming scheme), then you can use this quick little function. It comes in handy for debugging.
<?php
function returnConstants ($prefix) {
foreach (get_defined_constants() as $key=>$value)
if (substr($key,0,strlen($prefix))==$prefix) $dump[$key] = $value;
if(empty($dump)) { return "Error: No Constants found with prefix '".$prefix."'"; }
else { return $dump; }
}
?>
Example:
<?php
define("SITENAME_OPTION_ONE",true);
define("SITENAME_OPTION_TWO",false);
define("SITENAME_URL","foo");
print_r(returnConstants("SITENAME_OPTION"));
?>
Will return:
Array
(
[SITENAME_OPTIONONE] => 1
[SITENAME_OPTIONTWO] =>
)