php类中常量的用法举例 程序员文章站 2022-05-29 21:08:55 ... class Employee { //定义常量 const AVAILABLE = 0; const OUT_OF_STOCK = 1; public $status; } print Employee::AVAILABLE; ?> 复制代码 例2,定义类中的常量 class math_functions { //定义常量 const PI = '3.14159265'; const E = '2.7182818284'; const EULER = '0.5772156649'; /* 在这里定义其它的常量与方法... */ } echo math_functions::PI; ?> 复制代码 相关标签: php类中常量的用法举例 上一篇: php新手,问下一个小疑点 下一篇: ip签名探针_PHP教程 推荐阅读 php中isset与empty函数的困惑与用法分析 举例讲解Python面向对象编程中类的继承 简单掌握JavaScript中const声明常量与变量的用法 php中jpgraph类库的使用介绍 实例解析iOS应用多线程开发中NSthread类的用法 PHP中define() 与 const定义常量的区别详解 理解PHP中的stdClass类 从PHP的源码中深入了解stdClass类 [FAQ]PHP中的一些常识:类篇 Python中的对象,方法,类,实例,函数用法分析