Constants

Status
Not open for further replies.

Baljeet

Member
Jan 31, 2011
76
0
Constants

Constants are much like variables, except you can't change them. You can declare them at the beginning of a script and use them instead of any fixed number that you can't be sure will never change. PHP sets some constants for you, like TRUE, FALSE and NULL.

To create a constant, you use the define() function. Constants can be named just like variables, and they can store anything a variable can except an array.

PHP:
  define("MY_CONSTANT", "Hello World");
  echo MY_CONSTANT; // prints "Hello World"

A lot of mathematical constants are also preset for you when PHP starts up, namely M_PI for pi. Read the "Mathematical functions" section of the PHP manual for the complete list.

This tutorial was written by another one of my friends, if you would like to use this tutorial please send me a PM

All Credits goes to one who really made this...
 
Status
Not open for further replies.

Users who are viewing this thread

Top