我已经在Ruby编程几个月了,我想知道什么时候使用常量来适应类变量,反之亦然。 (我在Rails中工作,在模型中考虑常量)。 class Category
TYPES = %w(listing event business).freeze
end
OR class Category
@@types = %w(listing event business).freeze
我试过下面的代码在codepad.org: class test {
const TEST = 'testing 123';
function test() {
$testing = 'TEST';
echo self::$testing;
}
}
$class = new test;
而且它与返回: 1
2 Fatal error: A