Constant variable in PHP using define
by rajesh[ Edit ] 2010-01-02 19:31:12
The PHP constant is very similar to a PHP variable in that it is used to store a value but, unlike a variable, the value cannot be changed.
As the name indicates, the variable will be constant through out the programs life cycle.
We can use the function define to declare and set a value for the constant.
Example:
define("CONSTANT_NAME", "value");
echo CONSTANT_NAME;
This will give the output as "value"