Constants
Constants are defined using the define() function
- may only evaluate to scalar type values (e.g. int,float,string)
- have case-senstive names; written without dollar sign (
$ )
- are always available globally (like super-globals)
- may not be redefined or undefined once they have been set
define("CONSTANT", "Hello world.");
define("MaxLevel", 6);
echo CONSTANT; // outputs "Hello world."
echo Constant; // outputs "Constant" and gives error
if ($i > MaxLevel) { echo "Yes"; }
|
|