Php Constant

  • Constant of any assigned value never be change in an execution of program.
  • If assign value in a constant then the value of it never change means it stored value permanent.
  • define( ) function is used for define a constant it has three parameter.
  • parameter is  Name of Constant,Value of Constant and  Case-sensitive case-sensitive is optional for remove case-sensitive of constant name.
  • For remove the case-sensitive of constant name we pass the true in third parameter.
define("Name of constant","Value of Constant");



define("Message","Hello php!");

echo "constant Message=".$Message;

define("MSG","Hello world!");

echo "constant MSG".$MSG;



constant Message=Hello php!

constant MSG=Hello world!

Example after remove case-sensitive from constant


define("MSG","Hello world!",true);

echo "constant MSG".$msg;//we can call constant MSG as lower form msg using third optional parameter



constant MSG=Hello world!//after pass the true in third parameter remove the case-sensitive on constant name

12 Replies to “Php Constant”

Leave a Reply

Your email address will not be published. Required fields are marked *