Few difference between variables and constants in PHP are given below
Variables | Constants |
---|---|
The value of a variable can be changed during the execution. | The constant value can’t be changed during script execution. |
Variables require compulsory usage of the $ sign at the start. | No dollar sign ($) is required before using a constant. |
It is possible to define a variable by simple assignment. | Constants can’t be defined by simple assignments. They are defined using the define() function. |
The default scope is the current access scope. | Constants can be accessed throughout without any scoping rules. |