PHP Constant
Posted on: February 13, 2010 at 12:00 AM
Advertisement
In this tutorial you will come to know about constant in php, . You can store any kind of value which is not intend to change like mathematical constants like value of pi, paths to files etc.

PHP Constants:

Constants are like any other variables to store information but the difference between the constant and a variable is value of constant can not be changed but the value of the variable can be changed at any point of time. You can store any kind of value which is not intend to change like mathematical constants like value of pi, paths to files etc.

Example:

<?php

define("pi",3.14);

echo "Output of pi is :".pi."<br/>";

echo "If we would like to print constant within \"\" sign output would be: pi <br/> ";

echo "Since pi is a constant, we need not to use '$' sign before constant";

?>

Output:

Output of pi is :3.14
If we would like to print constant within "" sign output would be: pi
Since pi is a constant, we need not to use '$' sign before constant

 

Advertisement

Related Tags for PHP Constant:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 13, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com