Tutorial 4: Defining Constants


A constant is similar to a variable in the sense that you can store information in a keyword that can be used throughout your web page. However, the value of a constant cannot be changed, unlike a variable. It's literally "constant".

It's also worth noting that constants are case-sensitive and are written in ALL CAPS by convention. Here's how you define a constant in PHP:

define("TITLE", "Defining Constants");

To display a constant on your page, you can echo it using PHP, like this:

<?php echo TITLE; ?>