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

相关文章:

  • 2022-02-09
  • 2022-12-23
  • 2021-12-02
  • 2021-08-23
  • 2021-05-17
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-28
  • 2021-09-08
  • 2022-03-01
  • 2021-05-29
  • 2022-01-04
  • 2021-09-01
  • 2022-12-23
相关资源
相似解决方案