Constants
Constants are a special type of variable that don't get enough attention, in my humble opinion. Constants, as the name would imply, contain a value that does not, nor cannot, change during the course of a script. Furthermore, constants have the added advantage of being global in scope, meaning they are accessible within your functions automatically.
Constants are case-sensitive, as are all variables in PHP. As a rule, constants are always written in all uppercase letters. When naming constants, use the same rules as you do variables—a letter or underscore followed by letters, numbers, or underscores—but omit the initial dollar sign.
A constant is created by using the define() function, like so:
define ("CONSTANT_NAME", "value");
Get PHP Advanced for the World Wide Web: Visual QuickPro Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.