我有一个名称很长的静态类,例如:
class SomeClassWithAVeryLongName {
const CONST_ONE = 'foo';
const CONST_TWO = 'bar';
}
在我的其他课程中,我想引用这些常量。问题是它们有很多,我将它们用作关联键,所以我的代码变得非常冗长:
$someArray[SomeClassWithAVeryLongName::CONST_ONE][SomeClassWithAVeryLongName::CONST_TWO] = 'foobar';
有没有办法可以使用某种指针?就像是:
// Pseudo code
$scwavln = 'SomeClassWithAVeryLongName';
$someArray[$scwavln::CONST_ONE][$scwavln::CONST_TWO] = 'foobar';
它似乎对我不起作用。我在 PHP 5.2.6 上。