PHP constants are case-sensitive by default. Traditionally constant identifiers are always uppercase.
PHP constant names follow the same naming rules as any other PHP tag. Legal constant names begin with a letter or an underscore, followed by any letters, numbers, or underscores. The regular expression is expressed as follows: [a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*.
// Legal constant name
define("FOO", "something");
define("FOO2", "something else");
define("FOO_BAR", "something more" ");
//Illegal constant name
define("2FOO", "something");
// The following definition is legal, but should be avoided: (custom constants do not start with __)
// Maybe one day in the future PHP will define a magic constant of __FOO__
// This will conflict with your code
define("__FOO__", "something");
?>
Summary:
1. Custom constants
* Must be defined using the function define()
* After definition, its value cannot be changed
* When used, use the constant name directly, not like a variable Just add $s in front
2 System constants:
FILE: PHP program file name
LINE: PHP program file line number
PHP_VERSION: The version number of the current parser
PHP_OS: The name of the operating system that executes the current PHP version
__FILE__ The name of the script file currently being processed.
__LINE__ The current line number of the script file currently being processed, the same as before.
TRUE means true.
FALSE represents a false value (false).
E_ERROR This constant points to the most recent error.
E_WARNING This quantity refers to the nearest warning.
E_PARSE This constant is a potential problem in parsing syntax.