dtt83024 2014-06-11 09:22
浏览 298
已采纳

检查是否存在类常量

How can I check if a constant is defined in a PHP class?

class Foo {
    const BAR = 1;
}

Is there something like property_exists() or method_exists() for class constants? Or can I just use defined("Foo::BAR")?

  • 写回答

4条回答 默认 最新

  • dsfhe34889789708 2014-06-11 09:26
    关注

    Yes, just use the class name in front of the constant name.

    http://www.php.net/manual/en/function.defined.php#106287

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 nginx的使用与作用
  • ¥100 关于#VijeoCitect#的问题,如何解决?(标签-ar|关键词-数据类型)
  • ¥30 数字信号处理实验报告
  • ¥15 一个矿井排水监控系统的plc梯形图,求各程序段都是什么意思
  • ¥15 ensp路由器启动不了一直报#
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了
  • ¥15 数学建模数学建模需要