May 10, 2021 PHP
After the constant value is defined, it cannot be changed anywhere else in the script.
A constant is an identifier of a simple value. The value cannot be changed in the script.
A constant consists of letters, underscores, and numbers, but numbers cannot appear as initials. (Constant names do not require a $ modifier).
Note: Constants can be used throughout the script.
Set the constant, using the define() function, which has the following syntax:
bool define ( string $name , mixed $value [, bool $case_insensitive = false ] )
The function has three parameters:
case_insensitive: Optional parameter, which is case insensitive if set to TRUE. The default is case sensitive.
In the following example, we create a case-sensitive constant with a constant value of "Welcome w3cschool.cn!" :
In the following example, we create a case-insensiable constant with a constant value of "Welcome w3cschool.cn!" :
Tip: When using PHP, be aware of the difference between the constant and the variable.