Constant

Updated: 12/31/2022 by Computer Hope
Fictional keyboard keys named Same and Change

Const or constant is data or a value that does not change in a specified time, unlike a variable. For example, in a PHP (PHP: Hypertext Preprocessor) script, when a constant is defined, it remains the same throughout the script. Below is an example of how you'd define and use a constant.

define ('EXAMPLE', 'There is hope!\n');
echo 'Is there hope? ', EXAMPLE;

Entering the code above would return "Is there hope? There is hope!" in a PHP page.

Tip

It's common and preferred that constants be created in all uppercase.

Programming terms, Read-only, Static, Variable