php - Check if a variable with a name from a config file is set -
in php function, need check if variable set. variable name is, well, variable. can changed within config.php file. looks this:
//config.php class config { const array = 'name'; } so need check if variable name config::array (in case $name) exists. i've come with:
$array = config::array; if(isset($$array)) return true; notice 2 dollar signs. since $array == 'name', $$array becomes $name - @ least in theory. i've tested , seems working intended. however, i'm not sure if it's doing want - it? if yes, way of doing or there better one? if not, how do this?
thank you!
you should this:
$array = config::array; if (isset($$array)) { $array = $$array };
Comments
Post a Comment