Php – Constant
We have mainly worked with variables up to now. In most situations we need to use variables. But there are some exceptions where we need more reliable and constant values those will not changed during the execution of the applications. Php provides the constant type. Constants are designed to not changed during the application’s execution.
We will define constants with
define function. We will provide the name of the constant and the value the constant will refer. In this example we will define
Pi number as constant because it can not be changed because of its mathematical meaning and position.
echo "Pi number is ".PI;
As a general habit constants generally defined with the uppercase letters. We can not only define numeric constants also string constants like below.