Home > Article > Backend Development > php constants define and use php constants
2, System constants FILE:php program file name LINE: Number of lines of PHP program file PHP_VERSION: The version number of the current parser PHP_OS: The name of the operating system that executes the current PHP version It can be used directly. For example, if you want to check the name of the operating system running the current PHP version, you can write echo PHP_OS 3, php class constants Constants can be defined in classes. The value of a constant will always remain the same. There is no need to use the $ symbol when defining and using constants. The value of a constant must be a fixed value and cannot be the result of a variable, class attribute or other operation (such as a function call). Constants can also be defined in interfaces. See the interface's documentation for more examples. After PHP5.3.0, you can use a variable to dynamically call a class. But the value of this variable cannot be the keywords self, parent or static. Example 1. Define and use a class constant
Example 2, static data
|