SHARE
Facebook X Pinterest WhatsApp

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

Jan 29, 2007

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

Recommended for you...

Best Certifications for Database Administrators
Ronnie Payne
Oct 14, 2022
Become More Efficient at Writing TSQL by Creating Code Snippets
Gregory Larsen
Jun 30, 2021
Line Numbers in SQL Server Management Studio
Gregory Larsen
Sep 4, 2018
Couchbase Raises $60 Million to Fuel NoSQL Database Efforts
Sean Kerner
Jun 30, 2014
Database Journal Logo

DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.