Getting static property from a class with dynamic class name in PHP

后端 未结 11 523
情歌与酒
情歌与酒 2020-11-30 01:44

I have this:

  • one string variable which holds the class name ($classname)
  • one string variable with holds the property name ($propert
11条回答
  •  孤街浪徒
    2020-11-30 02:02

    I think this is the simplest:

    $foo = new ReflectionProperty('myClassName', 'myPropertyName'); 
    print $foo->getValue();
    

提交回复
热议问题