Forum : What is the PHP constant ?
Brief description  about Online courses   join in Online courses
View Abhijit  Paul 's Profile

What is the PHP constant ?

PHP constant.....
Asked by Abhijit Paul | Mar 17, 2010 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi Abhijit,
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. It is called a constant because; you guessed it, it stays constant throughout the PHP program. By using a constant you "lock in" the value which prevents you from accidentally changing it.
Example:
define("CONSTANT_NAME","VALUE");
define("state","karnataka");
echo state;
Mar 17, 2010