About Constants
Constants are a specific data type in PHP that, unlike variables, retain their initial value throughout the course of a script. In fact, you cannot change the value of a constant once it has been set. Constants can be assigned any single value—a number or a string of characters.
To create a constant, you use the define() function instead of the assignment operator (=) used for variables.
define ('NAME', 'value');
Notice that, as a rule of thumb, constants are named using all capitals, although this is not required. Most importantly, constants do not use the initial dollar sign as variables do (because, technically, constants are not variables).
Printing constants requires special syntax as well:
define ('USERNAME', 'trout'); ...
Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition 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.