Storing state between hook functions

Uing OOP for your plugin it’s very easy.

class MyPlugin {

    static $flag;

    static function function_a() {
      self::$flag = 'a value';
    }

    static function function_b() {
      if ( ! is_null(self::$flag) ) echo self::$flag; // echo 'A Value';
    }

}

add_action('plugins_loaded', array('MyPlugin', 'function_a') );
add_action('init', array('MyPlugin', 'function_b') );

Not using OOP you can use global variables.

function function_a() {
  global $myflag;
  $myflag = 'a value';
}

function function_b() {
  global $myflag;
  if ( ! is_null($myflag) ) echo $myflag; // echo 'A Value';
}

add_action('plugins_loaded', 'function_a' );
add_action('init', 'function_b' );

This works and seems easier, but first solution is better for sure.

tech