Note: Constant have the global characteristic, it means that constant can be accessed from any part in script without the abusively scope access.
To define a constant, you can use the function of define(). Only data type of scalar (boolean, integer, float, and string) which can be used as the data type of constant. The identifier name for constant is mould and declare without early with the dollar sign($).
Pay attention to the example of using constant at script as following:
File name: konstanta.php
<html>
<head>
<title>Using Konstanta</title>
</head>
<body>
<?
define ("interest", 0.12); // constant
$save = 50000000;
$saving = $save + ($save * interest);
printf ("interest = %s"."<br>", interest);
printf ("save = %s "."<br>", $save);
printf ("saving = %s"."<br>", $saving);
echo ("<h3>try to alter the value
of interest konstanta</h3>");
$interest = 0.15;
// mould interest as constant
printf ("interest = %s"."<br>", interest);
// mould interest as variable
printf ("interest = %s"."<br>", $interest);
?>
</body>
</html>
In the example of the script above, the changes of the $interest constant value and 0.15 is not have an effect when mould as constant.