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

Monday Jan 29th 2007 by DatabaseJournal.com Staff
Share:

In the last part of this series, we look at creating constants with the define() function, the constant() function, predefined and "magic" constants.

[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/

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved