Constants differ from normal variables in that you don't use the $ symbol to declare or use them.
<?php class MyClass { const constant = 'constant value'; function showConstant() { echo self::constant . " "; } } echo MyClass::constant . " "; $classname = "MyClass"; echo $classname::constant . " "; // 自 5.3.0 起 $class = new MyClass(); $class->showConstant(); echo $class::constant." "; // 自 PHP 5.3.0 起 ?>