A PHP constant is a simple value identifier (name ). As its name implies, this value cannot be changed during script execution (except for so-called magic constants, they are not constants)
A PHP constant is a simple value identifier (name ). As its name implies, this value cannot be changed during script execution (except for so-called magic constants, they are not constants)
PHP constants are case sensitive by default. Traditionally, constant identifiers are always capitalized.
PHP constant names and any other PHP labels follow the same naming rules. A valid constant name starts with a letter or underline followed by any letter, number, or underline. The regular expression is like this: [a-zA-Z _ \ x7f-\ xff] [a-zA-Z0-9 _ \ x7f-\ xff] *.
The Code is as follows:
// Valid constant name
Define ("FOO", "something ");
Define ("FOO2", "something else ");
Define ("FOO_BAR", "something more ");
// The constant name is invalid.
Define ("2FOO", "something ");
// The following definition is valid, but it should be avoided: (do not start with _ as a custom constant)
// Maybe one day, 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 define () function
* The value cannot be changed after definition.
* The constant name is used directly. You cannot add $ s in front of a variable.
2 system constants:
FILE: php program FILE name
LINE: Number of PHP Program Files
PHP_VERSION: version number of the current parser
PHP_ OS: name of the operating system for executing the current PHP version
_ FILE _ the script FILE name being processed.
_ LINE _ current number of rows of the script file being processed, same as the previous number.
TRUE indicates the true value (TRUE ).
FALSE indicates a pseudo value (false ).
The constant E_ERROR indicates the most recent error.
E_WARNING refers to the nearest warning.
E_PARSE this constant is a potential problem with the parsing syntax.