The Building Blocks: Data Types, Literals, Variables, and Constants – Part 3

[From WebReference]

Some real-world constants, such as pi, the speed of light, the number of inches in a foot, and the value of midnight, are values that don’t change. PHP not only provides its own predefined constants but lets you create your own. Using constants makes it easy to write and maintain your programs.

What Is a Constant?

Unlike variables, a constant is a value that, once set, cannot be changed or unset during the execution of your script. An example of a constant is the value of pi or the version of PHP you are using. Constants are very useful because they are visible throughout a program (global in scope) and their values don’t change; for example, a constant might be defined for the document root of your server, the name of your site, or the title, author, and copyright year of this book. Once defined, those values are fixed.

The article continues at

http://www.webreference.com/programming/php/by_example3/

Get the Free Newsletter!

Subscribe to Cloud Insider for top news, trends & analysis

Latest Articles