php类常量定制及使用方法
?
立即学习“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;
?>
?
立即学习“PHP免费学习笔记(深入)”;
?
立即学习“PHP免费学习笔记(深入)”;
输出结果如下:
?
立即学习“PHP免费学习笔记(深入)”;
?
立即学习“PHP免费学习笔记(深入)”;
利用内部方法输出常量值:http://www.my400800.cn
直接输出常量值:http://www.my400800.cn
?
立即学习“PHP免费学习笔记(深入)”;
输出结果截图如下:
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号