标签:
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 . "\n"; } } echo MyClass::constant . "\n"; $classname = "MyClass"; echo $classname::constant . "\n"; // 自 5.3.0 起 $class = new MyClass(); $class->showConstant(); echo $class::constant."\n"; // 自 PHP 5.3.0 起 ?>
标签:
原文地址:http://www.cnblogs.com/iMirror/p/4476140.html