Constant & ReadOnly
Difference between Constant & Read only: by Sagar Jaybhay
Constant – are compile-time constant and not assign a statickeyword to constant and also accessible in static method.
Value isset when the declaration performed means at the time declaration you can’tdeclare blank or null and then assign value is not possible.
- Data is absolutely constant then and then you can use constantly when values are absolutely constant.
Read-only- Is runtime constant means value is assigned atrun time in the constructor only you can’t be assigned value in the methods.
- Whenyou want to decide at first runtime and then through-out the program it remainsconstant.
- Afterthe first time initialization, you can’t change value.