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);
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);