Constants in PHP : using define()-function
Constant
A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script . A constant is case-sensitive by default. By convention, constant identifiers are always uppercase.
How can declare Constant ?
You can define a constant by using the define()-function. Once a constant is defined, it can never be changed or undefined.
<?php// Valid constant namesdefine("FOO", "something");define("FOO2", "something else");define("FOO_BAR", "something more");// Invalid constant namesdefine("2FOO", "something");
define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."?>
Important things ..
- Constants do not have a dollar sign ($) before them;
- Constants may only be defined using the define() function.
- Constants may only evaluate to scalar values (integer,float,boolean,strings).
tag:-Contants definition,How can declare constant in PHP ?,Constant Syntax in PHP