Check if a class constant exists

后端 未结 4 1335
醉梦人生
醉梦人生 2021-02-06 20:43

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

class Foo {
    const BAR = 1;
}

Is there something like property_exists()

4条回答
  •  北荒
    北荒 (楼主)
    2021-02-06 21:07

    You can check if a constant is defined with the code below:

提交回复
热议问题