8. Constants and Predefined Constants

Constants: A constant is an identifier for a simple value. A constant value cannot change during the execution of the script. By default, a constant is case-sensitive. constant identifiers are always uppercase. A constant name starts with a letter or underscore. If you have defined a constant, it can never be changed. To define a constant you have to use define() function

	define("GREETING", "Welcome to Constant area");

Predefined Constants:
PHP features a large number of built-in, predefined constants holding various useful values. Some of these are always available. For example, the PHP constant M_PI holds the mathematical constant Pi. The following code displays this value:

	echo M_PI;

Another useful predefined constant is PHP_VERSION, which holds the current version of the running PHP engine:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s