- constant: documentation ( source)
<?php
namespace SomeNamespace;
abstract class DictionaryKeepAliveIncrements{
CONST second = 1;
CONST quarterminute = 15;
CONST halfminute = 30;
CONST minute = 60;
}
class A {
public function getConst($name) {
return constant('SomeNamespace\DictionaryKeepAliveIncrements::'.$name);
}
public function doSomething() {
echo $this->getConst('minute');
}
}
$a = new A;
$a->doSomething();