: This article mainly introduces the differences between const and define. if you are interested in the PHP Tutorial, refer to it. 1. when using const to define constants, only scalar initialization can be used. when using define to define constants, we can use any form of expressions to initialize constants;
2. we can use define to define constants in conditional expressions, but const cannot. for example: defined ('debug') or define ('debug', true)
3. const defines the case sensitivity of constants; define defines constants through the third parameter to determine whether it is case sensitive. The third parameter is set to TRUE, indicating case sensitivity;
4. from PHP5.3, const can be used outside the class, and the previous version can only use const in the class;
The above introduces the difference between const and define, including the content, and hope to be helpful to friends who are interested in PHP tutorials.