PHP constants
A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script Constants are case-sensitive. By convention, constant identifiers are always uppercase.
- Constants variable are automatically global and can be used across the entire script.
- A valid constant variable name starts with a letter or underscore
Syntax
define(identifier,value,case-insensitive);
To create a constant variable , use the define() function.
Example
// Valid constant names
define("FOO", "something");
define("FOO2", "something else");
define("FOO_BAR", "something more");
// Invalid constant names
define("2FOO", "something");
Parameters
Parameters | Description |
---|---|
identifier | This parameter specifies the name of the constant |
value | This parameter specifies the value of the constant |
case-insensitive | This parameter contain bool value the constant name should be case-insensitive. Default is false |