Home > Article > Backend Development > Explanation of constants in php
An identifier of a simple value. Once a constant is defined, it cannot be changed while the script is running. This article mainly shares with you the explanation of constants in php, I hope it can help you.
System constants
1) PHP_VERSION php version
2) PHP_OS php running system
3) PHP_INT_MAX The maximum value of the integer
Custom constant
define(name, value)
Note:
const name = value
Use variables
Constant(name) Get the value of the constant based on its name
Detect whether the constantexists
defined(name)
true if it exists, otherwise returns false
Return all defined constantsget_defined_constants()
Magic variablesBetween
Starting and ending with an underscore :
_
LINE _
_ _ FILE_ _
_
DIR _
_
FUNCTION _
_
CLASS _
_
METHOD _
_
TRAIT _
_
NAMESPACE _
Instance analysis of variables and constants in PHP
Detailed explanation of constants and data types in PHP
Detailed analysis of constants and variables in PHP
The above is the detailed content of Explanation of constants in php. For more information, please follow other related articles on the PHP Chinese website!