>  기사  >  백엔드 개발  >  php种常量定制及使用方法

php种常量定制及使用方法

WBOY
WBOY원래의
2016-06-13 11:01:20883검색

php类常量定制及使用方法

?

实例代码如下:

/*
?* To change this template, choose Tools | Templates
?* and open the template in the editor.
*/

/**
?* Description of classConstSample
?*
?* @author liujl
?*/
class classConstSample {
??? const constVarTest="http://www.my400800.cn
";


??? static public function? showMsgTest() {
??????? echo "利用内部方法输出常量值:".self::constVarTest;
??? }

}

//常量调用输出测试
classConstSample::showMsgTest();
echo "直接输出常量值:".classConstSample::constVarTest;

?>

?

?

输出结果如下:

?

?

利用内部方法输出常量值:http://www.my400800.cn
直接输出常量值:http://www.my400800.cn

?

输出结果截图如下:


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.