In this article we will learn about how to define PHP Constant.
PHP Constant
Constants are similar to variable. They hold information
that can be accessed later, but once you define one, its value cannot be
altered.
define(“ROOT_LOCATION”,”user/local/www”);
Things to remember when defining PHP constant
·
PHP constants are not preceded by a dollar sign.
·
You can define constants with a define function.
·
It is a good practice to define constants with
upper case.
Predefined PHP constants
PHP comes ready made with many pre-declared constants. Few
are known as Magic Constants.
Magic constants always have two underscore at the beginning
and two at the end, so that you will not name your own constants with a name
that is already taken.
Example of php constants
echo “This”. __LINE__ . “ of file “ . __FILE__”;
0 comments :
Post a Comment