07 Jul PHP Constants
A constant once defined, cannot be undefined. A valid constant name starts with a letter or underscore (no $ sign before the constant name). PHP constants uses define() function for creating a constant.
Constant name starts with a letter or underscore, but they can’t be considered as a variable, since constant name once defined can’t be changed.
define() function is used for creating a constant. Here’s the syntax:
define(name, val, case-insensitive)
name is the constant name
val is the value of the constant
case-insensitive is for constant name insensitive.
define("RANKING", "ICC Rankings for Team!");
Here’s the output,
Above, you can see we haven’t mentioned the case section, since the default is false. If you want a case-insensitive name, use true i.e
define("RANKING", "ICC Rankings for Team!", true);
We used the define() function, since it is used for creating a constant.