How to define constant before plugin [duplicate]

Defining constants on the global scope instead of using WordPress hooks, the first plugin loaded (See answer linked by Kero) will get the chance to define the constant.

However, you could use some of the API hooks in your plugin, the earliest one possible is plugins_loaded, and then you can set priorities for the callbacks hooked into this so you can have the callback from plugin B executed before the callback from plugin A:

// code in plugin B
add_action('plugins_loaded', function(){
    if ( !defined('BLA') ) {
        define ( 'BLA', 'http://google.com' );
    }
}, 0); # <= 0 is the priority

// code in plugin A
add_action('plugins_loaded', function(){
    if ( !defined('BLA') ) {
        define ( 'BLA', 'http://google.com' );
    }
}); # <= priority is 10 by default.

That constant will then be accessible in any scope hooked into a WordPress action hook (init, plugins_loaded, wp, etc..).

// any other plugin
add_action('plugins_loaded', function(){
    echo BLA, PHP_EOL; # "http://google.com" hopefully
}, 11);

Hope that helps.