/** * Gets a flash variable and removes it from the variables * available to the next request (though it will still be available * for the remainder of the current request). * * If `$key` is NULL, gets the entire flash array. * * @param mixed variable to get (or NULL to get all) * @param mixed default value * @return mixed */ public static function get($key, $default = NULL) { isset(Flash::$config) or Flash::initialize(); if ($key !== NULL) { // Remove this key from the session, so it won't appear on // the next request and return the value unset(Flash::$session[$key]); return isset(Flash::$data[$key]) ? Flash::$data[$key] : $default; } else { Flash::$session = array(); return empty(Flash::$data) ? $default : Flash::$data; } }