【小记】动态调用 类静态属性 常量

时间:2021-03-05 13:15:20   收藏:0   阅读:0
class Foo {
    public static $flag_status = array( ‘foo‘, ‘bar‘ );

    Const OT_UPGRADE_1 = 1;
    Const OT_UPGRADE_2 = 2;
}

// 静态属性
$name_attr = ‘flag_status‘;
print_r(Foo::$$name_attr);


// 类动态常量
$rank = 1;
constant(Foo::class . ‘::OT_UPGRADE_‘ . $rank);

  

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!