How to define a Constant in PHP?
Constant can be declared using define()
function in PHP.
Constants are used instead of variables where its value is rarely changed. For an example, Tax rate is almost constant for many years. So we can define it in a constant rather than variable.
<?php
define("TAX", "14");
echo TAX;
?>
Note:
Note: Unlike with variables, we do not need to use doller ($) to output constant value.
Learn more about the similar topics:
Tutorials |
---|
PHP Constants |
Exercises & Assignments |
---|
No Content Found. |
Interview Questions & Answers |
---|
How to define a Constant in PHP? |