**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:**

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

Advertisements

Posted on: February 13, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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. Connect Me on Google+