首頁  >  文章  >  後端開發  >  php种常量定制及使用方法

php种常量定制及使用方法

WBOY
WBOY原創
2016-06-13 11:01:20884瀏覽

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