What is the best way to define a global constant in PHP which is available in all files?

constants, global-variables, php, variables

Solution

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');

Problem

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?

Original source