Get value of dynamically chosen class constant in PHP

前端 未结 8 1198
无人共我
无人共我 2020-11-29 03:38

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

class ThingIDs
{
    const Something = 1;
    const AnotherThing = 2;
}

$thing = \'Something\';
$id = Thi         


        
8条回答
  •  醉酒成梦
    2020-11-29 04:22

    getConstants();
        return isset($enum[$symbol])?$enum[$symbol]:false;
    }
    
    // print 'howdy'
    echo symbol_to_value('TEST', 'Dude');
    

提交回复
热议问题