Tag Archives: define function in php

What is constant in PHP ? what is define() function in php ?

31 Dec

Constant is different from variables .

Difference between constant and variable is : variable can have different value mean variable value can be modified. but constant value can not be modified once it is defined

Constants are named values whose values cannot be changed.

When we create constant we use all capital letters and underscore to represent constant. Dollar sign is not required in front of the constant name.

We use define() function to create constant

Lets have an example to initialize constant :

 <?php 

//define(constant_name, value, case_sensitive=true); 
define("TECHNOLOGY", "Javascript", true); 

echo "Given Technology is: " . TECHNOLOGY ;

?> 

Output :

Given Technology is: Javascript