How to use constants in PHP ?
Constants in php should not be declared/defined with $. Constants in any programming language will be used to store the predefined values.
PI -> 3.14
NEXTLINE -> \n etc..,
Sample PHP program with constants:
<?php define("NEXTLINE","\n"); echo "Hello ".NEXTLINE."world"; ?>
Here \n declared as a constant and used in the program without $.
Name of a constant can be a small letter also, but as per naming conventions it is recommended to use only capital letters to name the constants.
PHP Recommended Books:
919 total views, 1 views today