What is the best way to define a constant that is global, i.e., available in all PHP files?
UPDATE: What are the differences between constants and class constants? Can they be used interchangeably?
Define your constant in your top .php file, that will be included in all the other scripts. It may be your front controller, your config file, or a file created for this single purpose.
!defined('MY_CONST') && define('MY_CONST', 'hello');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With