constants are similar to variables, but constants cannot be changed or revoked once defined. PHP Constants
A constant is an identifier (name) for a single value. The value cannot be changed in the script.
Valid constant names begin with a character or underscore (there is no $ symbol in front of the constant name).
Note: Unlike variables, constants are automatically global throughout the script. Set PHP Constants
To set a constant, use the Define () function-it uses three parameters:
- The first parameter defines the name of the constant
- The second parameter defines the value of a constant
- The optional third parameter specifies whether the constant name is case-sensitive. The default is False.
The following example creates a case -sensitive constant with a value of "Welcome to w3school.com.cn!" : Instance
<? PHP Define ("Greeting", "Welcome to w3school.com.cn!" ); Echo greeting;? >
Running an instance
The following example creates a case -insensitive constant with a value of "Welcome to w3school.com.cn!" : Instance
<? PHP Define true ); Echo greeting;? >
Running an instance
"PHP Learning" PHP Constants