-
- class Employee {
- //Define constants
- const AVAILABLE = 0;
- const OUT_OF_STOCK = 1;
- public $status;
- }
- print Employee::AVAILABLE;
- ?>
Copy code
Example 2, define constants in classes
-
-
class math_functions { - //Define constant
- const PI = '3.14159265';
- const E = '2.7182818284';
- const EULER = '0.57721 56649';
- / * Define other constants and methods here... */
- }
echo math_functions::PI;
- ?>
-
Copy code
|