Constants

This page showcases the usage of constants in PHP.

Example 1: Defining and Using a Constant

Product price: 100
Tax rate: 7%
Tax amount: 7
Total price: 107

Example 2: Using Class Constants

User is eligible.User is not eligible.

Summary

While both serve as placeholders for values, constants and variables differ

Constants are useful for fixed values like mathematical constants or application-wide configurations. A variable's value can be changed or updated multiple times during the program's execution