A few differences between variables and constants in PHP are given below:
Constants | Variables |
There is no need to write a dollar ($) sign before a constant | A variable must be written with the dollar ($) sign |
Constants can only be defined using the define() function | Variables can be defined by simple assignment |
Constants may be defined and accessed anywhere without regard to variable scoping rules. | In PHP, functions by default can only create and access variables within their own scope. |
Constants cannot be redefined or undefined. | Variables can be redefined for each path individually. |