PHP Syntax Constants


- Info:

- A constant is a value that cannot be modified throughout the execution of a program once it is defined.

- Constant references are not prefaced with a dollar sign.

- Constants are global; they can be referenced anywhere in your script.

- Constants are defined using the define() function:

boolean define(string name, mixed value [, bool case_insensitive])


- Example:

- Create PHP Console Application Test.php.




define("PI", 3.141592);

printf("The value of pi is %f", PI); //The value of pi is 3.141592.

$pi2 = 2 * PI;

printf("Pi doubled equals %f", $pi2); //Pi doubled equals 6.283184.