PHP类常量的常见访问方法
PHP类常量的常见访问方法
class Math {
const num=3.14;
public function showNum(){
return self::num;
}
}
echo Math::num."<br/>";
$math=new Math();
echo $math->showNum();
结果:
3.14
3.14
- 上一篇 »PHP:第一章——PHP中静态变量和常量
- 下一篇 »php中const定义常量
PHP类常量的常见访问方法
class Math {
const num=3.14;
public function showNum(){
return self::num;
}
}
echo Math::num."<br/>";
$math=new Math();
echo $math->showNum();
结果:
3.14
3.14