PHP CONSTANTS
- A constant is an identifier (name) for a simple value.
- The value cannot be changed during the script.
- A valid constant name starts with a letter or underscore (no $ sign before the constant name).
- In Algebra, a constant is a number on its own, or sometimes a letter such as a, b or c to stand for a fixed number.
FIVE CONSTANTS IN PHP :
- The speed of light in vacuum, c;
- The Planck constant, h;
- The elementary charge, e;
- The Avogadro constant, NA;
- The Boltzmann constant, kB.
SYNTAX FOR CONSTANTS IN PHP :
const data_type constant_name = value;
EXAMPLE FOR CONSTANTS IN PHP :
< ! DOCTYPE html>
<html>
<body>
<?php
// case - sensitive constant name
define ("GREETING" , "Welcome to
dance program! " ) ;
echo GREETING;
</body>
</html>
?>
<html>
<body>
<?php
// case - sensitive constant name
define ("GREETING" , "Welcome to
dance program! " ) ;
echo GREETING;
</body>
</html>
?>
OUTPUT :
Welcome to dance program!